SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2004
    Location
    Winnipeg Canada
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I convert to BASE 16 in PHP 5?

    I have to pass a username to a webservice, and the API is asking for the following.

    1: The username has to be encrypted with AES
    2: The AES output has to be converted to BASE16
    3: It is the BASE16 value I have to pass.

    The encryption is easy - but I cannot find a way to convert the value to BASE16.
    PHP does not seem to have a BASE16_ENCODE like it does for BASE64.

    EG:
    $value = <AES Encrypted Username>;
    $base16username = base16_encode('$value'); (< Since Base16_encode does not exist, this is my problem)

    Google searches are leading me nowhere, nor is the PHP online manual so I suspect I might be overlooking something obvious.

    Any suggestions?

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2004
    Location
    Winnipeg Canada
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion.

    I have looked at base_convert, but I am not sure what I would be converting from.
    What base number is an AES encypted string?

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Zealot
    Join Date
    Feb 2004
    Location
    Winnipeg Canada
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    I looked at bin2hex as well - but the AES encryption string is not binary so that is not producing the expected results.

  6. #6
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,826
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Maybe sprintf('%x %X', your_number);


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
  •