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:
Then approximately from them hashes for training of a neural network turned out.
What gave about the following output:
Then it all turned bit by bit:
The result of work in such:
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.
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)
{
zz=0;
// 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 );
zz=stx.zzz;
What gave about the following output:
d34453f3c04552ee19cb6734ab71ad124710cfc98401570f73f65cb8cfa2a64d
6cc8ca5b918d1a22d5141494ad08b76a6c67cd5f649744f80d2fad4916b2b6d9
f89e9fd9609099b22924a77a5c8122c06118608c4287fca1cdafe5827249bce7
35280fd1e2289488828004682679452a070ccd90c12072fcb904529ab18e3f9d
1112c4cffb617c835874446f13c4d7d29fa091ba7ac996b776998f89dedffcc1
02e0521aae2d4ecdeb4482bda545bb222e1280ec1f580d5d23e29fb719252f70
Then it all turned bit by bit:
// printf("\n\n\nSUM=");// делаем строку обработанную sha256 двоичным кодомprintf ("%d 512 512",zz);
zf(str1);
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"); }
//printf("%s\n",str1);
jj=0; ii=0; // делаем строку обработанную sha256 двоичным кодом с пробеламиwhile(str2[jj]=str1[ii])
{
ii++;
jj=jj+2;
str2[jj-1]=*" ";
}
printf("%s",str2);
// 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.