public override void GenerateKey() { System.Security.Cryptography.TripleDES tdes = System.Security.Cryptography.TripleDES.Create(); tdes.Padding = PaddingMode.None; tdes.KeySize = this.KeySize; tdes.GenerateKey(); this._key = tdes; }
//create key and IV(vector) values for encryption public static byte[] Create3DESKey() { System.Security.Cryptography.TripleDES tDES = System.Security.Cryptography.TripleDES.Create(); tDES.KeySize = 128; tDES.GenerateKey(); tDES.Mode = CipherMode.ECB; return(tDES.Key); }
//create key and IV(vector) values for encryption public static byte[] Create3DESKey() { #if MONO byte[] tripleKey = new byte[16]; RandomNumberGenerator rng = RandomNumberGenerator.Create(); rng.GetNonZeroBytes(tripleKey); return(tripleKey); #else System.Security.Cryptography.TripleDES tDES = System.Security.Cryptography.TripleDES.Create(); tDES.KeySize = 128; tDES.GenerateKey(); tDES.Mode = CipherMode.ECB; return(tDES.Key); #endif }
/// <summary> /// 获得密钥数组 /// </summary> /// <returns>密钥数组</returns> private byte[] GetLegalKey() { string result = key; mCrypto.GenerateKey(); byte[] keyBytes = mCrypto.Key; int keyLength = keyBytes.Length; if (result.Length > keyLength) { result = result.Substring(0, keyLength); } else if (result.Length < keyLength) { result = result.PadRight(keyLength, ' '); } return(ASCIIEncoding.ASCII.GetBytes(result)); }
public override void GenerateKey() => _impl.GenerateKey();