Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Converting C# to Perl

by elmic11111 (Novice)
on Sep 18, 2012 at 20:58 UTC ( #994364=perlquestion: print w/ replies, xml ) Need Help??
elmic11111 has asked for the wisdom of the Perl Monks concerning the following question:

I'm not very familiar with C# and recently was given a example code piece to access a system through REST. The LWP agent stuff I can handle. But the system requires me to make use a HMAC created from three values as a special key. I though I could duplicate it with Digest::HMAC but seem to be doing something wrong.

Here the original code:

string dateTimeString = DateTime.UtcNow.ToString("R", CultureInfo.Inva +riantCulture); string hashString = ComputeHash(strTenant + dateTimeString, key);

Here what I wrote in perl:

my $dateTimeString = strftime('%a, %e %b %Y %T',localtime); my $data = $strTenant.$dateTimeString.' UTC'; $digest = hmac_md5($data, $pkey);

Comment on Converting C# to Perl
Select or Download Code
Re: Converting C# to Perl
by Illuminatus (Curate) on Sep 18, 2012 at 21:57 UTC
    A quick look at DateTime.UtcNow Doesn't show (at least on Windows) a day of the week as part of the format. Are you sure that your 2 date strings are exactly the same? Perhaps printing out the string to be hash'ed in both cases would at least rule differences out.

    fnord

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://994364]
Approved by bulk88
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2014-08-22 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (156 votes), past polls