/// <summary> /// 输入明文和密钥,输出密文 /// </summary> /// <param name="plainText"></param> /// <param name="key"></param> /// <returns></returns> public static string Encrypt(string plainText, string passwd, string saltValue) { if (string.IsNullOrEmpty(plainText)) { return(null); } byte[] bytesData = null; try { bytesData = new UTF8Encoding().GetBytes(plainText); } catch (Exception e) { DebugMod.LogException(e); return(null); } byte[] bytesResult = null; try { bytesResult = AesHelper.AesEncryptBytes(bytesData, passwd, saltValue); } catch (Exception e) { DebugMod.LogException(e); return(null); } return(ByteHelper.Bytes2HexString(bytesResult)); }
/// <summary> /// 获取指定字节流的SHA1值(HEX编码), 加入密码保护 /// </summary> /// <param name="data"></param> /// <returns></returns> public static string get_macsha1_string(byte[] data, string key) { byte[] bytes_sha1_out = get_macsha1_bytes(data, key); return(ByteHelper.Bytes2HexString(bytes_sha1_out)); }
/// <summary> /// 获取指定字节流的MD5值(HEX编码) /// </summary> /// <param name="data"></param> /// <returns></returns> public static string get_md5_string(byte[] data) { byte[] bytes_md5_out = MD5Core.GetHash(data); return(ByteHelper.Bytes2HexString(bytes_md5_out)); }
/// <summary> /// 获取字符串的SHA1值(HEX编码) /// </summary> /// <param name="str">输入的字符串</param> /// <returns></returns> public static string get_sha1_string(string str) { byte[] bytes_sha1_out = get_sha1_bytes(str); return(ByteHelper.Bytes2HexString(bytes_sha1_out)); }