2011-07-11, 08:17 PM
Ok, i'm writing a registration key script (a library to allow secure product registration) in vb.NET. I need the web element of it (providing the hash to compare to) to be written in PHP for the server side component.
This is the code in vb.NET used to encrypt the string (the opposite is used to decrypt):
Breakdown:
Can anyone help? Or does anyone know to use TripleDES-ECB in PHP? I can provide a test string, with key if you need to test it (or provide me with a hash created by your code and I'll test it with my decryptor )
Thanks guys
There's $10 PayPal in this for whoever creates the first working code
This is the code in vb.NET used to encrypt the string (the opposite is used to decrypt):
myKey = Validate.securityKey
cryptDES3.Key = cryptMD5Hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(myKey))
cryptDES3.Mode = CipherMode.ECB
Dim desdencrypt As ICryptoTransform = cryptDES3.CreateEncryptor()
Dim MyASCIIEncoding = New ASCIIEncoding()
Dim buff() As Byte = ASCIIEncoding.ASCII.GetBytes(myString)
Encrypt = Convert.ToBase64String(desdencrypt.TransformFinalBlock(buff, 0, buff.Length))
Breakdown:
myKey = Validate.securityKey
This gets the security key (like a password for - this is used by the decrypt function to decrypt the string)cryptDES3.Key = cryptMD5Hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(myKey))
This converts the key to MD5, in order to make sure it is 32 (?) bytes (I think). cryptDES3.Mode = CipherMode.ECB
This sets the cipher mode to ECB, not the most secure I know but its quickest for this purpose. Dim desdencrypt As ICryptoTransform = cryptDES3.CreateEncryptor()
This basically sets up the encryption algorithm. Dim MyASCIIEncoding = New ASCIIEncoding()
Not entirely sure if this is needed or no in the vb.NET code Dim buff() As Byte = ASCIIEncoding.ASCII.GetBytes(myString)
Converts the string to encrypt to a byte array, so the program can process it one byte (or block) at a time Encrypt = Convert.ToBase64String(desdencrypt.TransformFinalBlock(buff, 0, buff.Length))
Finally, convert it to Base64, one byte at a time.Can anyone help? Or does anyone know to use TripleDES-ECB in PHP? I can provide a test string, with key if you need to test it (or provide me with a hash created by your code and I'll test it with my decryptor )
Thanks guys
There's $10 PayPal in this for whoever creates the first working code