sha256 test for teeth for neural network

    Dear Colleagues.
    I found my old samples of reverse, unfortunately not the latest version.

    I don’t remember all the details very precisely, the experiment was conducted in 2012, but as they dig in the code, they emerge more and more clearly.

    Warning: Further code is taken out of context, description of its work is made from memory and may contain errors, is given only for educational purposes.

    This is how data for training and testing the neural network was prepared. First generated lines of this type, they are the desired result:

    spins : 0; server code word : 74b0dc5166334873643c9869327b23c6
    spins : 1; server code word : 46e87ccd238e1f29625558ec2ae8944a
    spins : 2; server code word : 79e2a9e341b71efb2eb141f2507ed7ab
    spins : 3; server code word : 4db127f8122008545bd062c2515f007c
    spins : 4; server code word : 140e0f7666ef438d1190cde71f16e9e8

    Then approximately from them hashes for training of a neural network turned out.

    FILE *fp;
    sha256_context stx;
    int ss,zz,yy,ii,jj,zzi;
    unsignedlongint pdata;
    fp = fopen("data_src", "rb");
        if(!fp) return1; // bail out if file not foundwhile(fgets(str,sizeof(str),fp) != NULL)
        // strip trailing '\n' if it existsint len = strlen(str)-1;
          if(str[len] == '\n') 
    	str[len] = 0;
    sha256_starts( &stx );
    sha256_update( &stx, (uint8 *) str, strlen( str ) );
    sha256_finish( &stx, sha256sum );

    What gave about the following output:


    Then it all turned bit by bit:

    // printf("\n\n\nSUM=");// делаем строку обработанную sha256 двоичным кодомprintf ("%d 512 512",zz);
    for( j = 0; j < 32; j++ )
    	  sprintf(str1,"%s%s",str1, ui2bin(sha256sum[j]));
    //дополняем строку до 512 битwhile(strlen(str1)<512) { sprintf(str1,"%s%s",str1,"0"); }
    jj=0; ii=0; // делаем строку обработанную sha256 двоичным кодом с пробеламиwhile(str2[jj]=str1[ii])
      str2[jj-1]=*" ";
    // str2 - результат sha2 побитно через пробел//printf("\n");

    The result of work in such:

    85514081408000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000110011100010111100011110010000000000000000000000000000000001100011001110001011110001111001000000000000000000000000000000000100100101000111110111100100011100000000000000000000000000000000010010010100011111011110010001110000000000000000000000000000000001010011010110011110100110110001100000000000000000000000000000000101001101011001111010011011000110000000000000000000000000000000000001000011111000011011111101000000000000000000000000000000000000000 [...]

    files were fed to the neural network as a training and test sample.
    FANN library was used, tried different neurons.
    The result was certainly, but was ambiguous. Fully restore the original text failed.
    However, sometimes fragments of parts of the lines skipped quite accurately restored.
    I think this problem has a solution, but to find it you still need to make an effort.
    For example, it makes sense to feed all internal variables of the hashing algorithm to the input of the network. It also makes sense to run competitive networks and teach another network to recognize the result of the consultation.
    These interesting experiments can be carried out now much easier than 2012.
    With the advent of tools like Python with Tensorflow, sklearn numpy, scipy and the treasury of the repository, it has become much easier to check.

    Also popular now: