c# - C to Perl Translation HMAC SHA1 , data and secret key -
c# - C to Perl Translation HMAC SHA1 , data and secret key -
i want convert c code below perl. know how this? utilize hmac_sha1_hex($data, $key);? utilize digest:sha module? want sign info key, utilize perl instead of c.
using system; using system.collections.generic; using system.text; using system.security.cryptography; using system.web; namespace amazon.cba.signature.common { public class signaturecalculator { public signaturecalculator() { } public string calculaterfc2104hmac(string data, string key) { string result = null; keyedhashalgorithm algorithm = new hmacsha1(); encoding encoding = new utf8encoding(); algorithm.key = encoding.getbytes(key); result = convert.tobase64string(algorithm.computehash(encoding.getbytes(data.tochararray()))); homecoming result; } } }
i so:
use mime::base64 (); utilize digest::hmac_sha1 (); $result = mime::base64::encode_base64( digest::hmac_sha1::hmac_sha1( $data, $key ), '' ); or if want url-safe base64 encoding:
my $result = mime::base64::encode_base64url( digest::hmac_sha1::hmac_sha1( $data, $key ), ); though can utilize separate digest::hmac , digest::sha modules together.
c# perl hmacsha1
Comments
Post a Comment