sonal wrote
Hi,
I am using DNN's Encrypt and Decrypt functions. I'll explain my scenario: I have an id field which is first encrypted on a page and then this value is decrypted on another page.This id is a part of the url so its encrypted but when i replace the encrypted value in the url with id value directly then also it works,which should not happen.What I mean is that the Decrypt function is not working properly. It returns the same value as given to it in the same way as it returns the encrypted value, i.e when i give the id directly then it should not return that id, rather it should return a value only for an encrypted value. I dont know the reason for this? Either I m going wrong somewhere or I am missing something. Any help??
Regards,
Sonal |
Sonal, this is the wrong forum. I would like to advise using the developing forum instead. Nevertheless your question made me curious, so I played some few minutes to catch the answer.
Inside the decrypt function the input will be converted from base64 to a byteArray, if this method fails the fuction will return the original input string:
' convert data to byte array and Base64 decode
Dim byteData(strData.Length) As Byte
Try
byteData = Convert.FromBase64String(strData)
Catch ' invalid length
strValue = strData
End Try
So the behaviour is by design. If you want to deny unencryted ids in your url, you can write code like:
dim id as string = decrypt(key, input_ID)
if id=input_id then ...'(throw exception)