[ patak_daca @ 27.02.2011. 15:31 ] @
Radim u MS SQL-u...

Imam table usera..
Kolonu userpass sa encrypt-ovao

Kada iz aplikacije prosledim parametar userpass koji nije encryptovan..
nedobijem nikakav rezultat.

code..

OPEN SYMMETRIC KEY PasswordFieldSymmetricKey
DECRYPTION BY CERTIFICATE PasswordFieldCertificate

SELECT * FROM user WHERE userpass = EncryptByKey(Key_GUID('PasswordFieldSymmetricKey'), @sifra)

ako neko ima iskustva...

pozz

patak daca
[ Dusan Kondic @ 28.02.2011. 07:37 ] @
> ako neko ima iskustva...

Ja koristim .NET rešenje.

Code:

        public static string Decrypt(string cipherText, string Password)
        {
            byte[] cipherBytes = Convert.FromBase64String(cipherText);

            PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,
                new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 
                    0x64, 0x76, 0x65, 0x64, 0x65, 0x76});

            byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(32), pdb.GetBytes(16));

            return System.Text.Encoding.Unicode.GetString(decryptedData);
        }

        public static string Encrypt(string clearText, string Password)
        {
            byte[] clearBytes =
              System.Text.Encoding.Unicode.GetBytes(clearText);

            PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,
                new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 
            0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76});

            byte[] encryptedData = Encrypt(clearBytes,
                     pdb.GetBytes(32), pdb.GetBytes(16));

            return Convert.ToBase64String(encryptedData);
        }
[ patak_daca @ 02.03.2011. 17:29 ] @
Hvala puno!

patak