v1shwa 0 Light Poster


I've been asked to create a tool using 3rd party API. The API requires to send the user details in encrypted format. The problem here, they didn't mention what kind of encryption we should do. They just provided a two C++ functions to encrypt the data.

I'm a PHP developer & couldn't understand exactly what those functions do. As far as I think, the are AES 256 CBC encryption. But it doesn't work.

Could someone please explain the code in plain english or PHP. Here are the two functions.

//add these namespaces
using System.Security.Cryptography;
using System.Text;

// for encrypting the id
public string AESEncrypt(string textToEncrypt)
     RijndaelManaged rijndaelCipher = new RijndaelManaged();
     rijndaelCipher.Mode = CipherMode.CBC;
     rijndaelCipher.Padding = PaddingMode.PKCS7;
     rijndaelCipher.KeySize = 0x80;
     rijndaelCipher.BlockSize = 0x80;
     byte[] pwdBytes = (byte[])Encoding.UTF8.GetBytes("ZENDROP77");
     byte[] keyBytes = new byte[0x10];
     int len = pwdBytes.Length;
     if (len > keyBytes.Length)
     len = keyBytes.Length;
     Array.Copy(pwdBytes, keyBytes, len);
     rijndaelCipher.Key = keyBytes;
     rijndaelCipher.IV = keyBytes;
     ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
     byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
     return Convert.ToBase64String(transform.TransformFinalBlock(plainText, 0,

 // for checking values through checksum
 public string GetCheckSum(string input)
     MD5 md5 = new MD5CryptoServiceProvider();
     byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
     byte[] ba = md5.ComputeHash(inputBytes);
     StringBuilder hex = new StringBuilder(ba.Length * 2);
     foreach (byte b in ba)
     hex.AppendFormat("{0:x2}", b);
     return hex.ToString();

Thank you.