Advertisement
Guest User

Untitled

a guest
Feb 24th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.49 KB | None | 0 0
  1. /*
  2. Hash Plugin test script
  3. */
  4.  
  5. #include <a_samp>
  6. #include <hash>
  7.  
  8. main() { }
  9.  
  10. new password[] = "The quick brown fox jumps over the lazy dog.";
  11. new iterations = 150000;
  12. new pbkdf2_hash[PBKDF2_LENGTH + 1], pbkdf2_salt[PBKDF2_LENGTH + 1];
  13.  
  14. compute()
  15. {
  16.     hash_generate(password, iterations, "OnPasswordHash", "i", GetTickCount());
  17. }
  18.  
  19. validate()
  20. {
  21.     hash_validate(password, pbkdf2_hash, pbkdf2_salt, iterations, "OnPasswordValidate", "i", GetTickCount());
  22. }
  23.  
  24. forward OnPasswordHash(tick);
  25. public OnPasswordHash(tick)
  26. {
  27.     hash_retrieve(pbkdf2_hash, pbkdf2_salt);
  28.     validate();
  29.     printf("OnPasswordHash %ims", hash_exec_time());
  30.     return 1;
  31. }
  32.  
  33. forward OnPasswordValidate(tick);
  34. public OnPasswordValidate(tick)
  35. {
  36.     if(hash_is_equal()) {
  37.         print("Correct password!");
  38.     } else {
  39.         print("Invalid password!");
  40.     }
  41.     printf("OnPasswordValidate %ims", hash_exec_time());
  42.     return 1;
  43. }
  44.  
  45. public OnGameModeInit()
  46. {
  47.     hash_thread_limit(3);
  48.     compute();
  49.  
  50.     new string1[10] = "YoSup?";
  51.     new string2[10] = "Yosup?";
  52.  
  53.     if(slow_equals(string1, string2))
  54.     {
  55.         print("string1 == string2");
  56.     } else print("string1 != string2");
  57.  
  58.     new pseudorandom_string[65];
  59.     for(new i = 0; i < 3; i++)
  60.     {
  61.         random_string(64, pseudorandom_string, sizeof(pseudorandom_string));
  62.         printf("random_string: %s (len: %i)", pseudorandom_string, strlen(pseudorandom_string));
  63.         printf("random_int: %i", random_int(0, 100));
  64.     }
  65.  
  66.     new string[64] = "The quick brown fox jumps over the lazy dog.";
  67.     new hash[129];
  68.    
  69.     print(string);
  70.     sha256(string, hash);
  71.     printf("sha256: %s (%i)", hash, strlen(hash));
  72.     sha384(string, hash);
  73.     printf("sha384: %s (%i)", hash, strlen(hash));
  74.     sha512(string, hash);
  75.     printf("sha512: %s (%i)", hash, strlen(hash));
  76.     whirlpool(string, hash);
  77.     printf("whirlpool: %s (%i)", hash, strlen(hash));
  78.     ripemd160(string, hash);
  79.     printf("ripemd160: %s (%i)", hash, strlen(hash));
  80.     ripemd256(string, hash);
  81.     printf("ripemd256: %s (%i)", hash, strlen(hash));
  82.     ripemd320(string, hash);
  83.     printf("ripemd320: %s (%i)", hash, strlen(hash));
  84.  
  85.     new file[32] = "server.cfg";
  86.     new checksum[129];
  87.  
  88.     print(file);
  89.     md5sum(file, checksum);
  90.     printf("md5sum: %s", checksum);
  91.     sha1sum(file, checksum);
  92.     printf("sha1sum: %s", checksum);
  93.     sha256sum(file, checksum);
  94.     printf("sha256sum: %s", checksum);
  95.     sha384sum(file, checksum);
  96.     printf("sha384sum: %s", checksum);
  97.     sha512sum(file, checksum);
  98.     printf("sha512sum: %s", checksum);
  99.     wpsum(file, checksum);
  100.     printf("wpsum: %s", checksum);
  101.     return 1;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement