开发者

base64 HmacSHA1 decode in iPhone

开发者 https://www.devze.com 2023-03-29 11:59 出处:网络
I am working on an iPhone application that requires Base64开发者_如何学Go decoding using HmacSHA1 algorithm. Can anyone help me doing the objective-C equivalent of the given Java code:

I am working on an iPhone application that requires Base64开发者_如何学Go decoding using HmacSHA1 algorithm. Can anyone help me doing the objective-C equivalent of the given Java code:

SecretKeykey = new SecretKeySpec(com.sinotar.algorithm.Base64.decode(
    "vNQKX3C1wD/KprnnOcdRwM80YIn5bo47w9VdTlDpCB8="), "HmacSHA1");

Thanks matthijz, But it has nothing to do with HmacSHA1. The solution I am looking for is something that does the equivalent of the Java code:

SecretKey key = null; 
try { key = new SecretKeySpec(com.sinotar.algorithm.Base64.decode("vNQKX3C1wD/KprnnOcdRwM80YIn5bo47w9VdTlDpCB8="), 
                              "HmacSHA1"); 
} 

Any help is appreciated.


Check out Matt Gallagher's article on Base64 encoding - it has downloadable code at the end. http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html


The code you quote appears to be taking a base64 value, converting it to binary, and using it to set the key for an HMACSHA1 algorithm. The two steps are conceptually separate.

Here is the page for HMAC_SHA1 on Mac -- I haven't found the equivalent for iPhone, but I would assume it exists.

0

精彩评论

暂无评论...
验证码 换一张
取 消