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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jwray
Visitor

HMAC issue

Hi,

trying to use the HMAC support from the library and running into an error I can't figure out. Any help would be great. My function:

Function HMAC(msg As String) As String
hmac = CreateObject("roHMAC")
privateKey = CreateObject("roByteArray")
privateKey.fromBase64String("k3U6GLkZOoNIoSgjDshPErvqMIFdE0xMTx8kgsrhnC0=")
result = hmac.setup("sha1", privateKey)
print "result";result
if result = 0
message = CreateObject("roByteArray")
message.fromAsciiString(msg)
result = hmac.process(message)
return result.toBase64String()
end if
End Function


and the resultant error:

Current Function:
274: Function HMAC(msg As String) As String
275: hmac = CreateObject("roHMAC")
276: privateKey = CreateObject("roByteArray")
277: privateKey.fromBase64String("k3U6GLkZOoNIoSgjDshPErvqMIFdE0xMTx8kgsrhnC0=")
278: result = hmac.setup("sha1", privateKey)
279: print "result";result
280: if result = 0
281: message = CreateObject("roByteArray")
282: message.fromAsciiString(msg)
283: result = hmac.process(message)
284: return result.toBase64String()
285: end if
286: End Function
/tmp/plugin/DEAAAAeOkGv7/pkg:/source/appMain.brs(278): runtime error ec: 'Dot' Operator attempted with invalid BrightScript Component or interface reference.

278: result = hmac.setup("sha1", privateKey)


I still have little experience with the platform so I could be missing something obvious but that makes no sense to me unless setup is not a method on the object.

thanks,
Jonny
0 Kudos
3 REPLIES 3
TheEndless
Channel Surfer

Re: HMAC issue

The problem is that you named your function the same as your variable (BrightScript is case insensitive), so it thinks you're trying to call .Setup() on your HMAC function rather than your hmac object.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jwray
Visitor

Re: HMAC issue

Told you I was new to Roku 🙂 Thanks a lot, I would have taken a long time to figure that one out.

Jonny

"TheEndless" wrote:
The problem is that you named your function the same as your variable (BrightScript is case insensitive), so it thinks you're trying to call .Setup() on your HMAC function rather than your hmac object.
0 Kudos
TheEndless
Channel Surfer

Re: HMAC issue

"jwray" wrote:
Told you I was new to Roku 🙂 Thanks a lot, I would have taken a long time to figure that one out.
Jonny

It would have taken me a long time, too, if I hadn't run into the same issue with a "configuration" object the other day. 😛 Welcome to the platform!
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.