fork(1) download
  1. using System;
  2. using System.Text;
  3. using System.Security.Cryptography;
  4.  
  5. public class Test
  6. {
  7. public static string GenerateMySQLHash(string strKey) {
  8. byte[] bytes = Encoding.UTF8.GetBytes(strKey);
  9. SHA1Managed sHA1Managed = new SHA1Managed();
  10. byte[] array = sHA1Managed.ComputeHash(sHA1Managed.ComputeHash(bytes));
  11. StringBuilder stringBuilder = new StringBuilder(array.Length);
  12. byte[] array2 = array;
  13. checked {
  14. for (int i = 0; i < array2.Length; i++) {
  15. byte b = array2[i];
  16. stringBuilder.Append(b.ToString("x2"));
  17. }
  18. return "*" + stringBuilder.ToString();
  19. }
  20. }
  21.  
  22. public static void Main()
  23. {
  24. string a;
  25. while ((a = Console.ReadLine())!=null)
  26. Console.WriteLine(a + " = " + GenerateMySQLHash(a));
  27. }
  28. }
  29.  
Success #stdin #stdout 0.03s 33864KB
stdin
trallaa
dsafa
sdf
stdout
trallaa  =  *3d3b45a9a0f1c1c70eb55cf59bfc367bd64e9521
dsafa  =  *0a97a2a20463db78c7770c3bdf2f11e503130d16
sdf  =  *7e1b02628187315a1854df1e4d3a80001fac469c