System.Security.Cryptography.AesCryptoServiceProvider crypto = new System.Security.Cryptography.AesCryptoServiceProvider(); crypto.KeySize = 128; crypto.BlockSize = 128; crypto.GenerateKey(); byte[] keyGenerated = crypto.Key; Key = Convert.ToBase64String(keyGenerated);
RijndaelManaged aes = new RijndaelManaged(); aes.BlockSize = 128; aes.KeySize = 128; /// In Java, Same with below code /// Cipher _Cipher = Cipher.getInstance("AES"); // Java Code aes.Mode = CipherMode.ECB; byte[] keyArr = Convert.FromBase64String(keyStr); byte[] KeyArrBytes16Value = new byte[16]; Array.Copy(keyArr, KeyArrBytes16Value, 16); aes.Key = KeyArrBytes16Value; ICryptoTransform encrypto = aes.CreateEncryptor(); byte[] plainTextByte = ASCIIEncoding.UTF8.GetBytes(PlainText); byte[] CipherText = encrypto.TransformFinalBlock(plainTextByte, 0, plainTextByte.Length); return Convert.ToBase64String(CipherText);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)