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 |
||
| 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) | |||
) | |||
INSERT INTO @tempCustomer VALUES ('utente-porco',ENCRYPTBYPASSPHRASE(N'culo-sale', N'nel mezzo di una matita mi ritrovai un culo di mezzo')) | |||
select * from @tempCustomer | |||
SELECT [UserName], CONVERT (nvarchar(1000), DECRYPTBYPASSPHRASE(N'culo-sale-culo-scende',[Password])) | |||
from @tempCustomer | |||
</syntaxhighlight> | |||
Versione delle 15:23, 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)
)
INSERT INTO @tempCustomer VALUES ('utente-porco',ENCRYPTBYPASSPHRASE(N'culo-sale', N'nel mezzo di una matita mi ritrovai un culo di mezzo'))
select * from @tempCustomer
SELECT [UserName], CONVERT (nvarchar(1000), DECRYPTBYPASSPHRASE(N'culo-sale-culo-scende',[Password]))
from @tempCustomer