none
Big picture question - LinqToSQL and encrypted fields RRS feed

Answers

  • I'm not quite sure I could understand you correctly , but I'll try my answer:

    If you want to bring encrypted or decrypted column from database to application with LINQ, do your SELECT clause in database as Function, encrypt or decrypt your column with giving some alias to it:

    SELECT CardNumber, CardNumber_Encrypted 
        AS 'Encrypted card number', CONVERT(nvarchar,
        DecryptByKey(CardNumber_Encrypted, 1 , 
        HashBytes('SHA1', CONVERT(varbinary, CreditCardID))))
        AS 'Decrypted card number' FROM Sales.CreditCard;

    (this is from example you've provided)

    ... and take your encrypted or decrypted data in application with LINQ


    Please mark as reply if helped.
    Also visit my blog http://msguy.net/

    Friday, November 2, 2012 2:29 PM