public string HashKey(string plainText) { if (string.IsNullOrWhiteSpace(plainText)) { return(string.Empty); } var plainTextBytes = Encoding.UTF8.GetBytes(plainText); var hash = new SHA384CryptoServiceProvider(); hash.Initialize(); return(Convert.ToBase64String(hash.ComputeHash(plainTextBytes))); }
/// <summary> /// SHA384 雜湊 /// </summary> /// <param name="text"></param> /// <returns></returns> public string HashBySHA384(string text) { if (string.IsNullOrWhiteSpace(text)) { return(string.Empty); } var textBytes = Encoding.UTF8.GetBytes(text); // SHA384 Hasher var hasher = new SHA384CryptoServiceProvider(); // 初始化 Hasher hasher.Initialize(); // 計算雜湊並轉換為 base64 字串 return(Convert.ToBase64String(hasher.ComputeHash(textBytes))); }