Esempio n. 1
0
 private static string GetSha384Hash(string text)
 {
     using (var sha = new System.Security.Cryptography.SHA384Managed())
     {
         return(Convert.ToBase64String(sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(text))));
     }
 }
Esempio n. 2
0
        public string GetSHA384Hash(string pathName)
        {
            string strResult   = "";
            string strHashData = "";

            byte[] arrbytHashValue;
            System.IO.FileStream oFileStream = null;

            System.Security.Cryptography.SHA384 oSHA384Hasher = new System.Security.Cryptography.SHA384Managed();

            try
            {
                oFileStream     = GetFileStream(pathName);
                arrbytHashValue = oSHA384Hasher.ComputeHash(oFileStream);
                oFileStream.Close();

                strHashData = System.BitConverter.ToString(arrbytHashValue);
                strHashData = strHashData.Replace("-", "");
                strResult   = strHashData;
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1);
            }

            return(strResult);
        }
Esempio n. 3
0
 /// <summary>
 /// SHA384加密,不可逆转
 /// </summary>
 /// <param name="str">string str:被加密的字符串</param>
 /// <returns>返回加密后的字符串</returns>
 private string SHA384Encrypt(string str)
 {
     System.Security.Cryptography.SHA384 s384 = new System.Security.Cryptography.SHA384Managed();
     byte[] byte1;
     byte1 = s384.ComputeHash(Encoding.Default.GetBytes(str));
     s384.Clear();
     return Convert.ToBase64String(byte1);
 }
Esempio n. 4
0
        public string GetSHA384Hash(string pathName)
        {
            string strResult = "";
            string strHashData = "";

            byte[] arrbytHashValue;
            System.IO.FileStream oFileStream = null;

            System.Security.Cryptography.SHA384 oSHA384Hasher = new System.Security.Cryptography.SHA384Managed();

            try
            {
                oFileStream = GetFileStream(pathName);
                arrbytHashValue = oSHA384Hasher.ComputeHash(oFileStream);
                oFileStream.Close();

                strHashData = System.BitConverter.ToString(arrbytHashValue);
                strHashData = strHashData.Replace("-", "");
                strResult = strHashData;
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1);
            }

            return (strResult);
        }