Forum Discussion

babuhari123's avatar
14 years ago

How to Send paramerter values in MD5 format in roTranferURL

Hi friend,

I have one new requirement in my project I need to send parameter using MD5 format in rotransferURL is it possible in Roku,
if possible can any one send me one small snippet for me please........

Thanks in advance

7 Replies

  • "babuhari123" wrote:
    Hi friend,

    I have one new requirement in my project I need to send parameter using MD5 format in rotransferURL is it possible in Roku,
    if possible can any one send me one small snippet for me please........

    Thanks in advance
    See if this helps:
    http://sdkdocs.roku.com/display/RokuSDKv43/roEVPDigest

    Example: MD5 Message Digest with roEVPDigest

    ba1 = CreateOjbect("roByteArray")
    ' ...populate ba1...
    ba2 = CreateObject("roByteArray")
    ba2.FromAsciiString(somestring)
    digest = CreateObject("roEVPDigest")
    digest.Setup("md5")
    digest.Update(ba1)
    digest.Update(ba2)
    result = digest.Final()
    print result
  • I am trying to send a hash key to my PHP script and am wondering how digest.Update(ba) formats the array of ascii numbers before it is hashed. I am trying to match the md5 on the PHP side and need to know how to simulate the method with the SDK builds the md5 hash.


    digest = CreateObject("roEVPDigest")
    digest.Setup("md5")
    ba=CreateObject("roByteArray")
    ba.FromAsciiString("10032012_salt")
    digest.Update(ba)
    key = digest.Final()
    output.URL = domain + "?key=" + key + "&date=10032012"


    The PHP uses $_REQUEST["date"] . "_" . "salt". Just need to know how to build the md5 from there.
  • I am still hoping that someone helps me out here.
    I can send the MD5 hash to my PHP file, but the issue is digest.Update(ba) converts ba into something other than a simple string that I need to match on the PHP side.
    Really all I want to do is something like

    digest.Update("10032012_salt")

    Then have my PHP script match the key.
    That's it. But you cannot just use a string.
  • Not sure if this helps, but here is an md5 signing function I wrote:


    '******************************
    '* sign url with md5 hash
    '******************************
    function makemdfive(urltosign as string) as string
    ba=createobject("robytearray")
    dg=createobject("roevpDigest")
    dg.setup("md5")
    ba.fromasciistring(urltosign)
    result=dg.process(ba)
    return result
    end function


    hope that is helpful.

    -Joel
  • I understand how to send it. The issue is result=dg.process(ba) turns the string into an array. With the PHP md5() function, it requires a string, so I need to understand how to match what Roku generates in this process with the PHP md5().

    What I am trying to do is expire requests, and also use a hidden value that both the Roku and Web Service will have to validate the request.

    Isn't this common practice for web requests on the Roku?

    If so, are there any known examples?

    I am searching but found nothing.
  • I think you have some fundamental misunderstanding which is why you're not getting a clear response to your question. First of all, roEvpDigest.Process doesn't turn any string into an array. It takes a ByteArray parameter and returns a string, which is the ASCII hex MD5 digest of the byte array. The code you originally posted actually seems to do the right thing, so I'm still not sure what your question is.

    --Mark
  • also, if you post your PHP code, perhaps that will help us understand why the output is different.

    - Joel