Sign In/My Account | View Cart  
advertisement

Article:
 Atom Authentication
Subject: Base64 encoding of SHA1 digest
Date: 2003-12-18 07:01:13
From: Piotr Lakomy

The base64 encoding of the SHA1(Password + CreationTimestamp + Nonce) should be "quR/EWLAV4xLf9Zqyw4pDmfV9OY".


Looks like example in the article applies base64 to to the hex encoding of SHA1 value:
base64("aae47f1162c0578c4b7fd66acb0e290e67d5f4e6") = "YWFlNDdmMTE2MmMwNTc4YzRiN2ZkNjZhY2IwZTI5MGU2N2Q1ZjRlNg=="
(Note two filler "=" charactes at the end).


Here is perl code to verify:


use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);;
use MIME::Base64 qw(encode_base64);


$password = "taadtaadpstcsm";
$nonce = "d36e316282959a9ed4c89851497a717f";
$timestamp = "2003-12-15T14:43:07Z";
$text = $nonce . $timestamp . $password;


print "text = $text\n";
print "SHA1 hex = " . sha1_hex($text) . "\n";
print "SHA1 b64 = " . sha1_base64($text) . "\n";
print "SHA1 b64(hex) = " . encode_base64(sha1_hex($text));


Very good article, I like it.




No Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • Base64 encoding of SHA1 digest
    2006-01-11 07:57:52 JY123 [Reply]

    Hi,
    I am working on a project that needs "Base64 encoding of SHA1 digest". Your article is very helpful. I have downloaded sha1 code from http://www.veign.com/vrc_codeview.asp?type=app&id=76, and wrote a Base64 code. Both are tested successfully using known examples.


    But I failed to reproduce your results when I calculate Base64(sha1(Nonce+TimeStamp+Password).
    The input string I used is:


    d36e316282959a9ed4c89851497a717f2003-12-15T14:43:07Ztaadtaadpstcsm


    But the result I got is:
    sha1=BADE76A5F7B0AFDE6D96BDEE566AAAACECEA7B75
    base64=QkFERTc2QTVGN0IwQUZERTZEOTZCREVFNTY2QUFBQUNFQ0VBN0I3NQ==


    I could not reproduce your result. What did I miss? Please let me know.


    Thanks
    Jack Yan

Sponsored By: