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.
精彩评论