I use the following function to encrypt data and save it to the registry
I know it is not secure, but the point was not to secure the data, just to really not make it readable and deter a user from editing the values themselves...VB Code:
Public Function EncryptPassword(strPass As String) As String Dim XOR_String As String Dim i As Integer For i = 1 To Len(strPass) XOR_String = XOR_String & Chr(Asc(Mid(strPass, i, 1)) Xor ((i * 5) Mod 256)) Next i EncryptPassword = XOR_String End Function
anyway our product has a CD key that is validated in the app using a simple algorithm. A problem was realized when a customer was able to activate with the key but then the internal function that validates it failed. Long story short, i found out that the encryption function produces odd results when certain characters are in certain locations in the string
XXXX-XXXX-7XXX-XXXX
XXXX-XXXX-XXAX-XXXX
XXXX-XXXX-XXXF-XXXX
XXXX-XXXX-XXXX-PXXX
XXXX-XXXX-XXXX-XUXX
XXXX-XXXX-XXXX-XXZX
I found this out by writing a quick program that encrypted and then decrypted each possible value and compaired it to the original string. So when the above keys have the certain char in a certain position this error occurs. I think the conversion may make it a carrage return or some unreadable character which is causing the error....
any ideas?
To test this out... pass "XXXX-XXXX-XXXF-XXXX" to the function to encrypt it and then decrypt it and compare to the original string.. it is cut off at the bad character...




Reply With Quote