public static String encryptString plain String key String mode String algorithm = KNOWN_MODESgetmode; if algorithm == null throw new IllegalArgumentException未知的加密模式: + mode; byte plainBytes
public static string Encrypt(string plain, string key, string mode) { string algorithm = KNOWN_MODES[mode]; if (algorithm == null) { throw new ArgumentException("未知的加密模式:" + mode); }
byte[] plainBytes = Encoding.UTF8.GetBytes(plain);
byte[] keyBytes = CreateKey(key, algorithm);
byte[] cipherBytes = CryptoUtils.Encrypt(plainBytes, keyBytes, algorithm, mode);
return BitConverter.ToString(cipherBytes).Replace("-", "").ToUpper();
}
原文地址: https://www.cveoy.top/t/topic/hJeE 著作权归作者所有。请勿转载和采集!