Note that there are some explanatory texts on larger screens.

plurals
  1. POrnddata digest issue
    primarykey
    data
    text
    <p>I tried to generate a big file for digest. When I used below openssl rand 8096 | head -c 8096 > rnddata, it was ok.</p> <p>./hash_test sha1<br> Digest is: a0a4dab4a16d247fb625ca2abf07373d2123e4a5<br> openssl dgst -sha1 rnddata<br> SHA1(rnddata)= a0a4dab4a16d247fb625ca2abf07373d2123e4a5 </p> <p>But the digest result was different when the rnddata's size is equal to or greater then 9000.</p> <p>openssl rand 9000 | head -c 9000 > rnddata<br> openssl dgst -sha1 rnddata<br> SHA1(rnddata)= 4ef5b73ee39f0f2ac6d341c55467c182786cab65<br> ./hash_test sha1<br> Digest is: 691747a97aee32ddf04b3bf5644b5d74c4b69657 </p> <p>Below is my c code for test</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;openssl/evp.h&gt; main(int argc, char *argv[]) { EVP_MD_CTX mdctx; const EVP_MD *md; FILE *fr; size_t bytes; char mystring[32]; fr = fopen("/home/root/rnddata", "r"); if(fr == NULL) printf("Error opening file\n"); unsigned char md_value[EVP_MAX_MD_SIZE]; int md_len, i; OpenSSL_add_all_digests(); //OpenSSL_add_all_algorithms(); if(!argv[1]) { printf("Usage: mdtest digestname\n"); exit(1); } //md = EVP_get_digestbyname(argv[1]); md = EVP_sha1(); if(!md) { printf("Unknown message digest %s\n", argv[1]); exit(1); } EVP_MD_CTX_init(&amp;mdctx); EVP_DigestInit_ex(&amp;mdctx, md, NULL); while ((bytes = fread (mystring, 1, 32, fr)) != 0) EVP_DigestUpdate(&amp;mdctx, mystring, bytes); EVP_DigestFinal_ex(&amp;mdctx, md_value, &amp;md_len); EVP_MD_CTX_cleanup(&amp;mdctx); printf("Digest is: "); for(i = 0; i &lt; md_len; i++) printf("%02x", md_value[i]); printf("\n"); fclose(fr); } </code></pre> <p>Any help is appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload