locked
Decryption Not Working RRS feed

  • Question

  • User709978785 posted

    I have been testing two way symmetrical encryption. I have been able to encrypt rows of a spacific column using the following UPDATE statement, however, when I try and decrypt them, the query returns Null for the effected rows.

    Can anyone see where I may have gone wrong in the decryption statement?

    UPDATE tblReceipts SET tblReceipts.CCNumber = EncryptByPassPhrase('Abracadabra!1234$',tblReceipts.CCNumber)
    FROM tblReceipts
    WHERE tblReceipts.CreditCardType > 0
    
    Decrypt Does Not Work?????
    
    SELECT CONVERT(varchar, DecryptByPassPhrase('Abracadabra!1234$',tblReceipts.CCNumber)) AS CCNumber
    FROM tblReceipts
    WHERE tblReceipts.CLIENTID = 15000
    My CCNumber field is nvarchar(20)
    My PassPhrase is just a test phrase
    The data after it is encrypted in just a bunch of binary looking boxes
     
     
    Tuesday, February 5, 2008 10:12 AM

Answers

  • User709978785 posted

    Ok, so just so some other newbie to encryption can use this stuff. I was able to return my original entry by changing nvarchar(200) to nvarchar(max)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 6, 2008 6:43 PM

All replies

  • User709978785 posted

    So deos anyone know why I would not be able to decrypt the selected rows?

    The column I'm encrypting is nvarchar(20), does this make a difference?

    Tuesday, February 5, 2008 7:07 PM
  • User709978785 posted

    Is there maybe another way to do this, that someone can suggest?

    Should the data be a bunch of binary boxes after it is encrypted?

    Or

    Should it be a bunch of alphnumeric characters?

    Wednesday, February 6, 2008 4:17 PM
  • User709978785 posted

    I have made progress but I still need help in understanding why the second select here would return only a 1

    I entered into the field 1234567890123456 so how do I return 1234567890123456 again?

    this returns 0x3100320033003400350036003700380039003000310032003300340035003600

    SELECT DecryptByPassPhrase('Abracadabra!1234$',tblReceipts.EncryptedCCNumber) as EncryptedCCNumber
    FROM tblReceipts
    WHERE tblReceipts.EncryptedCCNumber IS NOT NULL

    this returns a 1

    SELECT CAST(decryptByPassPhrase('Abracadabra!1234$',tblReceipts.EncryptedCCNumber) as varchar(200))
    FROM tblReceipts
    WHERE tblReceipts.EncryptedCCNumber IS NOT NULL

    Wednesday, February 6, 2008 6:06 PM
  • User709978785 posted

    I tried this again with some text and it looks like it is returning only the first character of what is in the EncryptedCCNumber field.

    Any ideas?

    SELECT CAST(decryptByPassPhrase('Abracadabra!1234$',tblReceipts.EncryptedCCNumber) as varchar(200))
    FROM tblReceipts
    WHERE tblReceipts.EncryptedCCNumber IS NOT NULL

    Wednesday, February 6, 2008 6:37 PM
  • User709978785 posted

    Ok, so just so some other newbie to encryption can use this stuff. I was able to return my original entry by changing nvarchar(200) to nvarchar(max)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 6, 2008 6:43 PM
  • User160496826 posted

    thanks

    Wednesday, January 15, 2014 1:10 AM