Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP: Characters and Order for base64-encode()

Posted on 2010-11-09
3
Medium Priority
?
330 Views
Last Modified: 2012-05-10
Wikipedia lists the Base64 index (in order): as this:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

Open in new window


However that does NOT seem to be the the index used by PHP.  What is the ordered Base64 index for PHP?

Oddly, the PHP manual does not seem to list this information.
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34093037
0
 
LVL 16

Author Comment

by:hankknight
ID: 34093201
That does NOT contain a complete ordered index as used by used by PHP.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 34093763
It may be as close as we can get.  From the PHP man pages:

"base64_encode — Encodes data with MIME base64"
http://us2.php.net/manual/en/function.base64-encode.php

Some research:
http://lmgtfy.com?q=MIME+base64

The Base64 encoding is designed to represent arbitrary sequences of octets in a form that need not be humanly readable. A 65-character subset ([A-Za-z0-9+/=]) of US-ASCII is used, enabling 6 bits to be represented per printable character.  This amounts to the required 64 characters and a pad character.

MIME's Base64 implementation uses A–Z, a–z, and 0–9 for the first 62 values.  I would expect + and / to be the last two characters.  Other variations, usually derived from Base64, share this property but may differ in the last two symbols (UTF-7).  An additional pad character , usually the = is used to force the encoded output into an integer multiple of 4 characters.  If you test with different strings, you will quickly realize that characters will be encoded differently depending on their position in the string.

An index table, and a table of variants is given here:
http://en.wikipedia.org/wiki/Base64

So I guess the question is, "Why do you think that PHP does not use the index that PHP says it uses?"  Is there a test case that you can show us to demonstrate what PHP is doing wrong?  I have probably sent over 100,000 base64 encoded strings to numerous different programs, and I've never gotten a complaint that it did not decode correctly.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question