using System.Security.Cryptography;
public static void Main()
var token = Encrypt("dt=20220511190000|api-key="+apiKey, encKey);
Console.WriteLine("api-key=" + apiKey + ";token=" + System.Net.WebUtility.UrlEncode(token));
public static string Encrypt(string plainText, string encryptionKey, int vectorBytesLength = 16)
RijndaelManaged rj = new RijndaelManaged();
rj.Mode = CipherMode.CBC;
byte[] key = new byte[32];
key = Enumerable.Range(0, encryptionKey.Length)
.Select(x => Convert.ToByte(encryptionKey.Substring(x, 2), 16))
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
byte[] nonce = new byte[vectorBytesLength];
MemoryStream ms = new MemoryStream();
using (CryptoStream cs = new CryptoStream(ms, rj.CreateEncryptor(key, iv), CryptoStreamMode.Write))
using (StreamWriter sw = new StreamWriter(cs))
byte[] encoded = ms.ToArray();
byte[] cyphertext = new byte[iv.Length + encoded.Length];
iv.CopyTo(cyphertext, 0);
encoded.CopyTo(cyphertext, iv.Length);
return Convert.ToBase64String(cyphertext);