CryptographyProvider.cs 967 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.IO;
  3. using System.Security.Cryptography;
  4. using System.Text;
  5. using MediaBrowser.Model.Cryptography;
  6. namespace Emby.Server.Implementations.Cryptography
  7. {
  8. public class CryptographyProvider : ICryptoProvider
  9. {
  10. public Guid GetMD5(string str)
  11. {
  12. return new Guid(ComputeMD5(Encoding.Unicode.GetBytes(str)));
  13. }
  14. public byte[] ComputeSHA1(byte[] bytes)
  15. {
  16. using (var provider = SHA1.Create())
  17. {
  18. return provider.ComputeHash(bytes);
  19. }
  20. }
  21. public byte[] ComputeMD5(Stream str)
  22. {
  23. using (var provider = MD5.Create())
  24. {
  25. return provider.ComputeHash(str);
  26. }
  27. }
  28. public byte[] ComputeMD5(byte[] bytes)
  29. {
  30. using (var provider = MD5.Create())
  31. {
  32. return provider.ComputeHash(bytes);
  33. }
  34. }
  35. }
  36. }