Posted Post

Posted People, Posted Life.

HMAC SHA1 Hash for Amazon S3

JavaScript packed ASP code for Amazon S3.

var Encryption = function(){

    var _Crypt = obj.get('ChilkatCrypt2.ChilkatCrypt2');
    _Crypt.UnlockComponent('your key');

    this.hmac_sha1 = function(hmac, str){
        _Crypt.HashAlgorithm = 'sha1';
        _Crypt.SetHmacKeyString(hmac);
        _Crypt.Charset = 'utf-8';
        _Crypt.EncodingMode = 'base64';
        return _Crypt.HmacStringENC(str);
    }

    this.md5 = function(str){
        _Crypt.HashAlgorithm = 'md5';
        _Crypt.Charset = 'utf-8';
        _Crypt.EncodingMode = 'Hex';
        return _Crypt.HashStringENC(str);
    }

}

1 Comment »

  rednael wrote @

Good post…

Please also read the following article:
http://blog.rednael.com/2008/09/30/SecuringYourPasswordTransfersWithKeyedHashingHMACCramMD5.aspx

It’s a walkthrough example of implementing HMAC-MD5 / Cram-MD5 on a website. The same technique can be used for various client-server situations.
The article explains the benefits of using such a password system and shows you how to implement it using the .Net library at server side (examples in C#), and using Paj’s MD5 Javascript functions at client-side.


Your comment

HTML-Tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>