hmac

HMAC signing requests in Python

拥有回忆 提交于 2019-12-21 12:16:42
问题 I'm trying to create an HMAC-SHA512 signed request for an API call in Python 3.4 using the requests library. I'm trying to follow docs, but am hitting this error: AttributeError: '_hashlib.HASH' object has no attribute 'new' Here's some code. It's failing with the error on the hmac constructor. It's fine if I try and pass hashlib.md5() or omit the digest parameter entirely. I'm not sure if I'm signing the request properly afterwards as I haven't got that far yet. The docs for the service I'm

Setting up Twitter OAuth without 3rd party libraries

夙愿已清 提交于 2019-12-20 14:25:13
问题 Continuation from Get twitter public timeline, json+C#, no 3rd party libraries I'm still new to C# and oAuth so please bear with me if I fail to understand anything I've created a C# class named oAuthClass, and these are the variables I currently have: static class oAuthClass { public static void run() { int oauth_timestamp = GetTimestamp(DateTime.Now); string oauth_nonce = PseudoRandomStringUsingGUID(); string oauth_consumer_key = "consumer key here"; string oauth_signature_method = "HMAC

Ruby and PHP HMACs not agreeing

孤街醉人 提交于 2019-12-20 12:21:34
问题 I'm trying to create an HMAC in Ruby and then verify it in PHP. Ruby: require 'openssl' message = "A522EBF2-5083-484D-99D9-AA97CE49FC6C,1234567890,/api/comic/aWh62,GET" key = "3D2143BD-6F86-449F-992C-65ADC97B968B" hash = OpenSSL::HMAC.hexdigest('sha256', message, key) p hash PHP: <?php $message = "A522EBF2-5083-484D-99D9-AA97CE49FC6C,1234567890,/api/comic/aWh62,GET"; $key = "3D2143BD-6F86-449F-992C-65ADC97B968B"; $hash = hash_hmac("sha256", $message, $key); var_dump($hash); ?> For the Ruby, I

xcode ios HMAC SHA 256 hashing

情到浓时终转凉″ 提交于 2019-12-20 09:54:14
问题 So I'm trying to figure out how to do a hmacshad256 hash on ios as that's the hash I did for the wcf service api I made. I've been trying to look for some info about it but would usually just end up getting a SHA-256 hash. This is the only reference I have: Need to generate HMAC SHA256 hash in Objective C as in Java And I'm not sure if that's the only way to do it (importing a java hmac class) Any help is appreciated. Thanks! 回答1: NSString * parameters = @"string to hash" NSString *salt = @

HMAC-based one time password in C# (RFC 4226 - HOTP)

為{幸葍}努か 提交于 2019-12-20 09:33:04
问题 I am attempting to wrap my brain around generating a 6 digit/character non case sensitive expiring one-time password. My source is http://tools.ietf.org/html/rfc4226#section-5 First the definition of the parameters C 8-byte counter value, the moving factor. This counter MUST be synchronized between the HOTP generator (client) and the HOTP validator (server). K shared secret between client and server; each HOTP generator has a different and unique secret K. T throttling parameter: the server

Calculate HMAC-SHA256 digest in ColdFusion using Java

耗尽温柔 提交于 2019-12-19 07:32:14
问题 We are trying to calculate a HMAC-SHA256 digest in ColdFusion and we are using the HMAC CFC, but in one case it is producing a different result for the digest compared to ones generated in different languages - have tried the same data using Ruby & PHP and get the expected result. I have also tried the CF_HMAC custom tag it is based on and get the same results. I understand that from CF8 encrypt() supports HMAC-SHA256, but it's only available in Enterprise (which we don't have) and isn't even

HMAC SHA256 hex digest of a string in Erlang, how?

删除回忆录丶 提交于 2019-12-19 05:44:51
问题 I am trying to interact with third party real time Web messaging System created and maintained by Pusher.com . Now, i cannot send anything through the API unless i produce an HMAC SHA256 hex digest of my data. A sample source code written in ruby could try to illustrate this: # Dependencies # gem install ruby-hmac # require 'rubygems' require 'hmac-sha2' secret = '7ad3773142a6692b25b8' string_to_sign = "POST\n/apps/3/channels/test_channel/events\nauth_key=278d425bdf160c739803&auth_timestamp

Node JS crypto, cannot create hmac on chars with accents

情到浓时终转凉″ 提交于 2019-12-18 19:49:43
问题 I am having an issue generating the correct signature in NodeJS (using crypto.js) when the text I am trying to encrypt has accented characters (such as ä,ï,ë) generateSignature = function (str, secKey) { var hmac = crypto.createHmac('sha1', secKey); var sig = hmac.update(str).digest('hex'); return sig; }; This function will return the correct HMAC signature if 'str' contains no accented characters (chars such as ä,ï,ë). If there are accented chars present in the text, it will not return the

C# help required to Create Facebook AppSecret_Proof HMACSHA256

核能气质少年 提交于 2019-12-18 13:08:58
问题 Facebook requires that I create a appsecret_proof: https://developers.facebook.com/docs/graph-api/securing-requests And I have done this using the following code: public string FaceBookSecret(string content, string key) { var encoding = new System.Text.ASCIIEncoding(); byte[] keyByte = encoding.GetBytes(key); byte[] messageBytes = encoding.GetBytes(content); using (var hmacsha256 = new HMACSHA256(keyByte)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); return Convert

C# help required to Create Facebook AppSecret_Proof HMACSHA256

醉酒当歌 提交于 2019-12-18 13:08:06
问题 Facebook requires that I create a appsecret_proof: https://developers.facebook.com/docs/graph-api/securing-requests And I have done this using the following code: public string FaceBookSecret(string content, string key) { var encoding = new System.Text.ASCIIEncoding(); byte[] keyByte = encoding.GetBytes(key); byte[] messageBytes = encoding.GetBytes(content); using (var hmacsha256 = new HMACSHA256(keyByte)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); return Convert