public static string Create(string userDetails)
{
string accountKey = "ucdavis";
string apiKey = "b7bce8a7c70fb5eca0c1dc0fb4e01cc9";
string initVector = "OpenSSL for Ruby"; // DO NOT CHANGE
byte[] initVectorBytes = Encoding.UTF8.GetBytes(initVector);
byte[] keyBytesLong;
using (var sha = new SHA1CryptoServiceProvider())
{
keyBytesLong = sha.ComputeHash(Encoding.UTF8.GetBytes(apiKey + accountKey));
}
var keyBytes = new byte[16];
Array.Copy(keyBytesLong, keyBytes, 16);
byte[] textBytes = Encoding.UTF8.GetBytes(userDetails);
for (int i = 0; i < 16; i++)
{
textBytes[i] ^= initVectorBytes[i];
}
// Encrypt the string to an array of bytes
byte[] encrypted = encryptStringToBytes_AES(textBytes, keyBytes, initVectorBytes);
string encoded = Convert.ToBase64String(encrypted);
return HttpUtility.UrlEncode(encoded);
}