php - Why aren't these SHA1 implementations alike? -


my question simple -- 2 separate sha1 implementations, guaranteed sames output same input, or there space interpretation in implementation?

most r digest sha1 implementation , php sha1 digest don't seem come like. have bug or sha1 implementations giving different valid hashes of same message?

in r :

digest_token = "stackoverflow cool" value = digest(digest_token, "sha1", raw=false) 

output :

[1] 4c 70 99 2f 81 b5 32 0d 77 aa 17 b6 da 69 92 13 a0 44 9f 

in php

$digest_token= "stackoverflow cool"; $value = sha1($disgest_token, false);  

output

ef48c200b5d9b844c950f7704e6c03359f8a4e2f 

i might expect these 2 produce same output not.

the r digest package description pretty clear what's going on (emphasis mine):

the digest function applies cryptographical hash function arbitrary r objects. by default, objects internally serialized, , either 1 of implemented md5 , sha-1 hash functions algorithms can used compute compact digest of serialized object.

in order compare implementation others, serialization of input argument can turned off in input argument must character string digest returned.

the following code produces same result php code:

digest_token = "stackoverflow cool" value = digest(digest_token, "sha1", raw=false, serialize=false) 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo