CryptographyProvider.cs 775 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.IO;
  3. using System.Security.Cryptography;
  4. using System.Text;
  5. using MediaBrowser.Model.Cryptography;
  6. namespace Emby.Common.Implementations.Cryptography
  7. {
  8. public class CryptographyProvider : ICryptographyProvider
  9. {
  10. public Guid GetMD5(string str)
  11. {
  12. return new Guid(GetMD5Bytes(str));
  13. }
  14. public byte[] GetMD5Bytes(string str)
  15. {
  16. using (var provider = MD5.Create())
  17. {
  18. return provider.ComputeHash(Encoding.Unicode.GetBytes(str));
  19. }
  20. }
  21. public byte[] GetMD5Bytes(Stream str)
  22. {
  23. using (var provider = MD5.Create())
  24. {
  25. return provider.ComputeHash(str);
  26. }
  27. }
  28. }
  29. }