DEFINITIONS

Definitions More Info.
Definition ID70
TitleSQL
CategorySCRIPT
DefinitionENCRYPT_ETMEK
Definition DescriptionUSE AdventureWorks; GO -- Create a column in which to store the encrypted data. ALTER TABLE Sales.CreditCard ADD CardNumber_EncryptedbyPassphrase varbinary(256); GO -- First get the passphrase from the user. DECLARE @PassphraseEnteredByUser nvarchar(128); SET @PassphraseEnteredByUser = 'A little learning is a dangerous thing!'; -- Update the record for the user's credit card. -- In this case, the record is number 3681. UPDATE Sales.CreditCard SET CardNumber_EncryptedbyPassphrase = EncryptByPassPhrase(@PassphraseEnteredByUser , CardNumber, 1, CONVERT( varbinary, CreditCardID)) WHERE CreditCardID = '3681'; GO USE AdventureWorks; select * from users GO --BENIM KOD CALISTI use Fatura -- Create a column in which to store the encrypted data. ALTER TABLE users ADD password_EncryptedbyPassphrase varbinary(256); GO -- First get the passphrase from the user. DECLARE @PassphraseEnteredByUser nvarchar(128); SET @PassphraseEnteredByUser = 'gggg' -- Update the record for the user's credit card. -- In this case, the record is number 3681. UPDATE users SET password_EncryptedbyPassphrase = EncryptByPassPhrase('gggg', users.[password], 1, CONVERT( varbinary, ID)) WHERE ID = '1'; GO -- Decrypt the encrypted record. SELECT users.[password], password_EncryptedbyPassphrase AS 'Encrypted card number', CONVERT(nvarchar, DecryptByPassphrase('gggg', password_EncryptedbyPassphrase, 1 , CONVERT(varbinary, ID))) AS 'Decrypted card number' FROM users WHERE ID = '1';
RecordBycunay
Record Date15-02-2012 16:33:51
Düzenle
Kopyala
Sil