HMAC_MD5 encryption algorithms (Javascript & Perl)

Hey PG folks.  I've attached two samples of code for creating the HMAC_MD5 pg_ts_hash in languages that you didn't already have listed in your documentation and developer's forum.  You are welcome to publish these examples.

 

 

For PERL:

 

#!/usr/bin/perl

 

use Digest::HMAC_MD5 qw(hmac_md5_hex);

 

# generate hex hash of message with secret key

my $digest = hmac_md5_hex("MESSAGE_TEXT","SECRET_KEY");

 

print $digest;

 

 

 

For Javascript:

 

<script type="text/javascript" src="http://crypto-js.googlecode.com/files/2.2.0-crypto-md5.js"></script>

<script type="text/javascript" src="http://crypto-js.googlecode.com/files/2.2.0-hmac-min.js"></script>

<script type="text/javascript">

     // Generate hex hash of message with secret key

     var hmac = Crypto.HMAC(Crypto.MD5, "MESSAGE", "SECRET_KEY");

</script>

 

 

[Contributor's notes]   I would not recommend the Javascript example as the Secret Key would be viewable by anyone who viewed the source of the HTML document, but it certainly works and for something like an intranet, or internal use only, it would be fine.

Disclaimer: These examples have been provided by users and have not been thoroughly tested under all conditions. ACH Direct and Payments Gateway, therefore, cannot guarantee or imply reliability, serviceability, or function of this code.

All code contained herein are provided to you "AS IS" without any warranties of any kind

Follow Us

Stay up to date with the latest PG news via RSS, Twitter and Google +1

Copyright © 2012 Payments Gateway - All Rights Reserved Privacy | Legal