hmac

Base64_encode different between Java and PHP

一曲冷凌霜 提交于 2019-12-02 06:33:02
Here is my problem : I have a JAVA function to generate an encrypted string. I have to do the same thing in PHP. My Java function : String generateSignature () { byte[] Sequence = ("hello").getBytes("UTF-8"); Mac HMAC = Mac.getInstance("HMACSHA256"); HMAC.init("SECRET_KEY"); byte[] Hash = HMAC.doFinal(Sequence); String Signature = new String(Base64.encodeBase64(Hash)); return Signature; } My PHP function : function generateSignature() { $sequence = "hello"; $encrypted = hash_hmac('sha256', $sequence, "SECRET_KEY"); return base64_encode($encrypted); } The return value of the two functions are

HMAC SHA256 macro in Excel

会有一股神秘感。 提交于 2019-12-02 06:20:32
I search ed through google, tech forums, etc.... but I couldn't find a good tutorial/guide that answer my question: I have a Cell in Excel with Text, and a Cell with a Key(both text), is there a way to have an HMAC for EXCEL function that get both cell as input and return the hmac text ? thanks in advance A quick search on Google revealed a HMAC-SHA256 class written in VB6, located here: http://www.vbforums.com/showthread.php?635398-VB6-HMAC-SHA-256-HMAC-SHA-1-Using-Crypto-API Whilst this is for VB6 (and is native code), it should be straightforward to adapt for use with VBA. As it sounds that

PHP / Javascript / JQuery - base64 sha256 encoding

帅比萌擦擦* 提交于 2019-12-01 14:28:30
I'm trying to port a PHP example of an API integration to Javascript / JQuery. In PHP, an encrypted string is created using the following code: $sig = base64_encode(hash_hmac('sha256', $sign, $this->secretAccessKey, true) whose functions are documented here: http://php.net/manual/en/function.hash-hmac.php http://us.php.net/base64_encode In Javascript, I'm using JQuery's crypto to do the HMAC piece: http://code.google.com/p/crypto-js/#HMAC-SHA256 and I'm trying to figure out if I also need to do a base64 encode, as it seems it is already in base64. This is the code I'm currently running: var

SHA-256 hashing function in Java ME/J2ME

最后都变了- 提交于 2019-12-01 14:20:55
I've posted this question on the Nokia Developer forums so please bear with me. I'm writing an app which needs to find the SHA-256 hash of a URL keyed with a unique value – i.e. hmac('sha256', '27/3', '9EWVFmHpHN6n2YKW9QtvUqX3xbsFQUBovlrFddqnF7fpcSDA2q') . What would be the best way to do this in Java ME/J2ME? I've found many examples using the Mac class but this isn't supported in Java ME/J2ME. Thanks in advance. I managed to get things working, the solution is as follows: Digest digest = new SHA256Digest(); HMac hmac = new HMac(digest); hmac.init(new KeyParameter(appKeyHere)); hmac.update

SHA-256 hashing function in Java ME/J2ME

大兔子大兔子 提交于 2019-12-01 12:45:45
问题 I've posted this question on the Nokia Developer forums so please bear with me. I'm writing an app which needs to find the SHA-256 hash of a URL keyed with a unique value – i.e. hmac('sha256', '27/3', '9EWVFmHpHN6n2YKW9QtvUqX3xbsFQUBovlrFddqnF7fpcSDA2q') . What would be the best way to do this in Java ME/J2ME? I've found many examples using the Mac class but this isn't supported in Java ME/J2ME. Thanks in advance. 回答1: I managed to get things working, the solution is as follows: Digest digest

PHP / Javascript / JQuery - base64 sha256 encoding

你说的曾经没有我的故事 提交于 2019-12-01 12:40:17
问题 I'm trying to port a PHP example of an API integration to Javascript / JQuery. In PHP, an encrypted string is created using the following code: $sig = base64_encode(hash_hmac('sha256', $sign, $this->secretAccessKey, true) whose functions are documented here: http://php.net/manual/en/function.hash-hmac.php http://us.php.net/base64_encode In Javascript, I'm using JQuery's crypto to do the HMAC piece: http://code.google.com/p/crypto-js/#HMAC-SHA256 and I'm trying to figure out if I also need to

PHP and C# HMAC SHA256

此生再无相见时 提交于 2019-12-01 08:07:32
问题 I need to convert the following php code in C#: $res = mac256($ent, $key); $result = encodeBase64($res); where function encodeBase64($data) { $data = base64_encode($data); return $data; } and function mac256($ent,$key) { $res = hash_hmac('sha256', $ent, $key, true);//(PHP 5 >= 5.1.2) return $res; } I use the following C# code: byte[] res = HashHMAC(ent, key); string result = System.Convert.ToBase64String(res); where public byte[] HashHMAC(string ent, byte[] key) { byte[] toEncryptArray

Getting current MachineKey, or equivilent, for HMAC (in web-farm)

让人想犯罪 __ 提交于 2019-12-01 07:14:33
I am using HMACSHA256 for message authentication in a web-farm environment. Within the web-farm each machine has the same machine key, so the ViewState will work across machines, however, I need to do HMAC message authentication which will work across machines, so I figured that since all machines use the same machine key, there should be a way to derive a key from that to use as the HMAC key. I notice that as of .NET 4.0 there is the MachineKey class, however, I am stuck with using .NET 3.5 , and this is unavailable to me. Is there a way to get some sort key that is the same on all machines

When to use RS256 for JWT?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 06:15:22
So, right now I'm building an API for third parties uses and I was reading about RS256 and HS256. What I understood was that diff between is that in the first one you use a public key to verify and a private key to sign, and the other one, use just one key.. So if you use RS256 if because you want to keep your secret key secure and want the client to verify the token, but what I don't understand why you would like to verify the token in the client? Because you do a post request to the server, then it sends you back a token and whenever you want to make an authorized request you just use that

Getting current MachineKey, or equivilent, for HMAC (in web-farm)

橙三吉。 提交于 2019-12-01 05:27:16
问题 I am using HMACSHA256 for message authentication in a web-farm environment. Within the web-farm each machine has the same machine key, so the ViewState will work across machines, however, I need to do HMAC message authentication which will work across machines, so I figured that since all machines use the same machine key, there should be a way to derive a key from that to use as the HMAC key. I notice that as of .NET 4.0 there is the MachineKey class, however, I am stuck with using .NET 3.5