Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with SHA-256 (roEVPDigest)

Hi all,
We have a mechanism for authenticating our REST APIs at my company based on an HMAC token. This token is generated using a pre-shared key and some hashing functions, specifically SHA-256. I initially implemented the hashing of a string as:

Function computeSHA256Hash(data as String) as String
ba = CreateObject("roByteArray")
digest = CreateObject("roEVPDigest")
return digest.Process(ba)
End Function

The problem is that the implementation on other platforms takes TWO parameters to the SHA function, the key and the data, but this seems to only take data. For comparison, here is the iOS function (in the Common Crypto library):

- (NSData *)hmacSHA256WithKey:(NSData *)key
unsigned char buffer[CC_SHA256_DIGEST_LENGTH] = {0};

CCHmac(kCCHmacAlgSHA256, [key bytes], [key length],
[self cStringUsingEncoding:NSUTF8StringEncoding], [self length], buffer);

return [NSData dataWithBytes:buffer length:CC_SHA256_DIGEST_LENGTH];

The specifics are not important, except that as you see it takes a key and data. Is there a way on the Roku to compute an HMAC with SHA-256 in this way?
0 Kudos
Roku Employee
Roku Employee

Re: Help with SHA-256 (roEVPDigest)

It sounds like you want look at roHMAC (
0 Kudos

Re: Help with SHA-256 (roEVPDigest)

Perfect, thanks! Now iOS and Roku are in sync on the HMAC output.
0 Kudos