fork download
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Text;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. byte[] saltBytes = Convert.FromBase64String("YMgvriNfwJloaGPLmnqmtw==");
  10. byte[] passwordBytes = Encoding.Unicode.GetBytes("Julio.22"); // DNN usa UTF-16
  11.  
  12. var pbkdf2 = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
  13. byte[] hashBytes = pbkdf2.GetBytes(20); // 160 bits
  14.  
  15. Console.WriteLine(Convert.ToBase64String(hashBytes));
  16.  
  17. Console.WriteLine(Convert.ToBase64String((new Rfc2898DeriveBytes("Julio.22", System.Convert.FromBase64String("YMgvriNfwJloaGPLmnqmtw=="))).GetBytes(20)));
  18.  
  19. byte[] bytes = Encoding.Unicode.GetBytes("Julio.22");
  20. byte[] src = Convert.FromBase64String("YMgvriNfwJloaGPLmnqmtw==");
  21. byte[] dst = new byte[src.Length + bytes.Length];
  22. Buffer.BlockCopy(src, 0, dst, 0, src.Length);
  23. Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
  24. HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
  25. byte[] inArray = algorithm.ComputeHash(dst);
  26. Console.WriteLine(Convert.ToBase64String(inArray));
  27.  
  28. }
  29. }
Success #stdin #stdout 0.06s 30376KB
stdin
1
2
10
42
11
stdout
LixuuImmbhYZO3X8Qc+KN7VIHI8=
MSVZDppiEgCGW3K5I9n2kKT58ZA=
36gmDAf/5ruGxenN83aMXHKt/Wg=