Alpha Video Training
Results 1 to 4 of 4

Thread: *to_hex trick question

  1. #1
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,838

    Default *to_hex trick question

    This is a trick question but it took me several hours to figure out why this below was true, and what to do about it. Its important if you are working with hex and hash values for any purpose.

    Question:
    when is *TO_HEX(CC) not equal to *TO_HEX(CC)
    CC="abc-100" for this example.

    Case - I have a function in an application that has to 'register' with my main server. It makes a HTTP_POST call from the client's application, sending the value in CC and returns the results of the following script (simplified):

    cc = *to_hex(CC)
    cc = *md5(cc)

    Unfortunately, the results never matched. For the exact same value of CC ("abc-100" in this example), the client computer generated "93f77c768f08a798346418a156a1a041" while the registration server returned "28e99731d06ab570bf0ecedfbea7fba7".
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  2. #2
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: *to_hex trick question

    What trick?
    The argument should be an integer number, not character.
    Is that the trick?
    That's not to say you can't do it with Character. It is supposed to take binary, though I am not sure if alpha meant that.
    Last edited by G Gabriel; 05-31-2010 at 10:36 PM.

  3. #3
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,838

    Default Re: *to_hex trick question

    The Help Doc is incorrect, the function takes any alphanumeric string and converts to proper hex.

    The trick is my application runs on V10, but my registration server is on V9.

    On V10, *to_hex("abc-100") returns "6162632d313030" and V9 returns "6162632D313030", and that little case change makes the md5 hash completely different.

    Another test, ?*to_hex("abcdefghijklmnop"). V10 returns "6162636465666768696a6b6c6d6e6f70" and V9 all caps.

    According to wikipedia, there is no rule about upper/lower case for the alpha symbol in hex, but I did not expect them to be different between V9 and V10. Of course, I fixed the proplem by using upper() to render all alpha characters upper case.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  4. #4
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: *to_hex trick question

    Steve:
    I can't say anything about v9 or v10, but if you are getting these results, then I'd say it's a bug. The correct answer is D not d. I did it with my own home-made hex conversion, came out as D not d.

Similar Threads

  1. Trick to widen row selector buttons in browse
    By rmcgaffic in forum Alpha Five Version 9 - Desktop Applications
    Replies: 1
    Last Post: 08-15-2008, 11:20 PM
  2. Replies: 48
    Last Post: 11-19-2006, 11:12 PM
  3. Neat trick??
    By dtheo in forum Alpha Five Version 4
    Replies: 4
    Last Post: 02-13-2001, 12:20 PM
  4. Need Field Rules Trick
    By Rhett Scott in forum Alpha Five Version 4
    Replies: 2
    Last Post: 05-30-2000, 04:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •