public static string SHAHash(SNDK.Enums.SHAHashAlgorithm HashAlgorithm, string PlainText, string Salt) { string result = string.Empty; HashAlgorithm hash = null; byte[] plaintextbytes; switch (HashAlgorithm) { case SNDK.Enums.SHAHashAlgorithm.SHA1: hash = new SHA1Managed(); break; case SNDK.Enums.SHAHashAlgorithm.SHA256: hash = new SHA256Managed(); break; case SNDK.Enums.SHAHashAlgorithm.SHA384: hash = new SHA384Managed(); break; case SNDK.Enums.SHAHashAlgorithm.SHA512: hash = new SHA512Managed(); break; } if (Salt != string.Empty || Salt != null) { plaintextbytes = Encoding.UTF8.GetBytes(PlainText + Salt); } else { plaintextbytes = Encoding.UTF8.GetBytes(PlainText); } byte[] plaintexthash = hash.ComputeHash(plaintextbytes); foreach (byte x in plaintexthash) { result += String.Format("{0:x2}", x); } return(result); }
public static string SHAHash(SNDK.Enums.SHAHashAlgorithm HashAlgorithm, string PlainText) { return(SNDK.Crypto.SHAHash(HashAlgorithm, PlainText, string.Empty)); }