Kaushalye Kapuruge wrote:

Hi,
I tried to get the base64 encoded result of a SHA1 digest. But the result is not compatible with the same operation in Java. Also I tried to use a javascript function. It is matching with the result of the Java implementation but not with the openssl result. So I guess there is something wrong with openssl implementation.
Here I'll write my approaches.

(A) Openssl
------------------------------------
echo "abcde" | openssl dgst -sha1 -binary | openssl base64


(B) Java implementation.
----------------------------------
       MessageDigest md = MessageDigest.getInstance("SHA1");
       md.reset();
       md.update("abcde".getBytes());
       System.out.println(Base64.encode(md.digest()));


(C) Javascript
------------------------------------
var res= b64_sha1("abcde");
[Have to include the script file <script type="text/javascript" src="http://pajhome.org.uk/crypt/md5/sha1.js";></script>]

Also I tried this with SHA1() function in openssl/sha1 and it produces another result.(Let's say approach D)

If I summarize the results.
Approach A,B produces the same result. (A95sVwv+JL/DKMzXyka3bq2vQzQ=)
Approach C,D produces different results.

Thanks,
Kaushalye


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]


Hi,

Try this:
echo -n "abcde" | openssl dgst -sha1 -binary | openssl base64

Witek

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to