(I had this working a long time ago, now trying to re-construct it due to some computer issues.)
Private Function Encrypt(ByRef pPassPhrase As String, ByVal pTextToEncrypt As String) As String
If pPassPhrase.Length > 16 Then
'limitation of the encryption mechanism
pPassPhrase = pPassPhrase.Substring(0, 16)
If pTextToEncrypt.Trim.Length = 0 Then
'the Text to encrypt not set!!!
Dim skey As New Encryption.Data(pPassPhrase)
Dim sym As New Encryption.Symmetric(Encryption.Symmetric.Provider.Rijndael)
Dim objEncryptedData As Encryption.Data
objEncryptedData = sym.Encrypt(New Encryption.Data(pTextToEncrypt), skey)
Public Function Decrypt(ByRef pPassPhrase As String, ByVal pHexStream As String) As String
Dim objSym As New Encryption.Symmetric(Encryption.Symmetric.Provider.Rijndael)
Dim encryptedData As New Encryption.Data
encryptedData.Hex = pHexStream
Dim decryptedData As Encryption.Data
decryptedData = objSym.Decrypt(encryptedData, New Encryption.Data(pPassPhrase))
Catch ex As Exception
The evaluation copy of my software generates a "lock" using the encryption method, a hard-coded passphrase, and the id of the user's motherboard. For example, the result might look like this:
When the user is ready to register the software, they send me the lock. I enter it into a text box in my KeyMaker, which uses the Decrypt method to generate a "key". I then send that key to the user. The user enters the key into a dialog box that compares it to the lock and if everything matches, the software becomes a registered version.
The Keymaker software was lost due to some computer problems, but I remember enough to reconstruct it, except that I keep getting this error when I try to Decrypt the values entered into a text box:
"length of the data to decrypt is invalid"
I have seen numerous posts about this (enough to thoroughly confuse me), but most refer to the "cure" as changing both the encryption and decryption methods. I would prefer not to change the encryption method if at all possible, as I am pretty happy with the way my software is working now and don't want to mess with it again.
I hope the issue is clear.
Thanks in advance for any and all responses!