Beispiel #1
0
 /// <summary>
 /// 以UTF-8编码计算字符串指定模式的SHA值。
 /// </summary>
 /// <param name="input">需要计算SHA值的字符串。</param>
 /// <param name="mode">计算SHA的模式。</param>
 /// <returns>字符串对应的SHA值。</returns>
 /// <exception cref="ArgumentException">传入不能识别的ShaMode时将抛出该异常。</exception>
 public static string ComputeSha(string input, ShaMode mode)
 {
     return(Encryption.ComputeSha(input, Encoding.UTF8, mode));
 }
Beispiel #2
0
 /// <summary>
 /// 计算IO流的128位SHA512值。
 /// </summary>
 /// <param name="stream">需要计算SHA512值的IO流。</param>
 /// <returns>IO流对应的128位SHA512值。</returns>
 /// <exception cref="ArgumentNullException">参数stream为null时将抛出该异常。</exception>
 public static string ComputeSha(Stream stream)
 {
     return(Encryption.ComputeSha(stream, ShaMode.SHA512));
 }
Beispiel #3
0
 /// <summary>
 /// 以指定的编码方式计算字符串的40位SHA1值。
 /// </summary>
 /// <param name="input">需要计算SHA1值的字符串。</param>
 /// <param name="encoding">字符串的编码方式。</param>
 /// <returns>字符串对应的40位SHA1值。</returns>
 /// <exception cref="ArgumentNullException">参数encoding为null时将抛出该异常。</exception>
 public static string ComputeSha(string input, Encoding encoding)
 {
     return(Encryption.ComputeSha(input, encoding, ShaMode.SHA1));
 }
Beispiel #4
0
 /// <summary>
 /// 以UTF-8编码计算字符串的40位SHA1值。
 /// </summary>
 /// <param name="input">需要计算SHA1值的字符串。</param>
 /// <returns>字符串对应的40位SHA1值</returns>
 public static string ComputeSha(string input)
 {
     return(Encryption.ComputeSha(input, Encoding.UTF8));
 }