SHARE
TWEET

Looks for string with lowest sha512 hash - single thread

rainman002 Feb 16th, 2014 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <openssl/sha.h>
  6.  
  7. int main(int argc, char** argv)
  8. {
  9.     int iter = 1000000;
  10.    
  11.     uint64_t dataMin;
  12.     unsigned char outputMin[64] = {0xff};
  13.    
  14.     if(argc > 1) iter = atoi(argv[1]);
  15.    
  16.     uint64_t data = 0;
  17.     unsigned char output[64];
  18.    
  19.     data &= 0x1f1f1f1f1f1f1f1fll;
  20.     data |= 0x4040404040404040ll;
  21.     for(int x=0 ; x<iter ; x++)
  22.     {
  23.         SHA512((unsigned char*)&data, 8, output);
  24.         for(int i=0 ; i<64 ; i++)
  25.         {
  26.             if(output[i] < outputMin[i])
  27.             {
  28.                 memcpy(outputMin, output, 64);
  29.                 dataMin = data;
  30.                 break;
  31.             }
  32.             else if(output[i] > outputMin[i])
  33.             {
  34.                 break;
  35.             }
  36.         }
  37.         data |= 0xe0e0e0e0e0e0e0e0ll;
  38.         data += 1;
  39.         data &= 0x1f1f1f1f1f1f1f1fll;
  40.         data |= 0x4040404040404040ll;
  41.     }
  42.    
  43.     for(int i=0 ; i<8 ; i++)
  44.         printf("%c", ((char*)&dataMin)[i]);
  45.     puts("");
  46.    
  47.     for(int i=0 ; i<64 ; i++)
  48.         printf("%.2x", outputMin[i]);
  49.     puts("");
  50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top