Crypt.cs 688 B

1234567891011121314151617181920212223
  1. using System;
  2. using System.Text;
  3. using System.Security.Cryptography;
  4. namespace IFramework.Net
  5. {
  6. public static class Crypt
  7. {
  8. public static string ToSha1Base64(this string value,Encoding encoding)
  9. {
  10. SHA1 sha1 = new SHA1CryptoServiceProvider();
  11. byte[] bytes = sha1.ComputeHash(encoding.GetBytes(value));
  12. return Convert.ToBase64String(bytes);
  13. }
  14. public static string ToMd5(this string value,Encoding encoding)
  15. {
  16. MD5 md5 = new MD5CryptoServiceProvider();
  17. byte[] bytes = md5.ComputeHash(encoding.GetBytes(value));
  18. return Convert.ToBase64String(bytes);
  19. }
  20. }
  21. }