Encrypt/Decrypt password: differenze tra le versioni
Da Webmobili Wiki.
Creata pagina con "Usiamo due funzioni standard di SQL Server: * ENCRYPTBYPASSPHRASE * DECRYPTBYPASSPHRASE" |
Nessun oggetto della modifica |
||
| (2 versioni intermedie di uno stesso utente non sono mostrate) | |||
| Riga 1: | Riga 1: | ||
Usiamo due funzioni standard di SQL Server: | Usiamo due funzioni standard di SQL Server: | ||
* ENCRYPTBYPASSPHRASE | * ENCRYPTBYPASSPHRASE([Stringa per il sale],[password in chiaro]) | ||
* DECRYPTBYPASSPHRASE | * DECRYPTBYPASSPHRASE([Stringa per il sale],[password cifrata]) | ||
Esempio | |||
<syntaxhighlight lang='sql'> | |||
DECLARE @tempCustomer table ( | |||
[UserName] VARCHAR(50), | |||
[Password] VARBINARY(1000) | |||
) | |||
DECLARE @passphrase nvarchar(200) = 'culo-sale-culo-scende' | |||
INSERT INTO @tempCustomer VALUES ('utente',ENCRYPTBYPASSPHRASE(@passphrase, N'nel mezzo di una matita mi ritrovai in culo un cammino')) | |||
select * from @tempCustomer | |||
SELECT [UserName], CONVERT (nvarchar(1000), DECRYPTBYPASSPHRASE(@passphrase,[Password])) | |||
from @tempCustomer | |||
</syntaxhighlight> | |||
Versione attuale delle 15:36, 5 apr 2022
Usiamo due funzioni standard di SQL Server:
- ENCRYPTBYPASSPHRASE([Stringa per il sale],[password in chiaro])
- DECRYPTBYPASSPHRASE([Stringa per il sale],[password cifrata])
Esempio
DECLARE @tempCustomer table (
[UserName] VARCHAR(50),
[Password] VARBINARY(1000)
)
DECLARE @passphrase nvarchar(200) = 'culo-sale-culo-scende'
INSERT INTO @tempCustomer VALUES ('utente',ENCRYPTBYPASSPHRASE(@passphrase, N'nel mezzo di una matita mi ritrovai in culo un cammino'))
select * from @tempCustomer
SELECT [UserName], CONVERT (nvarchar(1000), DECRYPTBYPASSPHRASE(@passphrase,[Password]))
from @tempCustomer