XHTML.net

Technology talks by Loïc d’Anterroches

News, articles, PHP, scripts, XHTML/CSS, …

  1. Home
  2. News

Utilisation d'une chaîne encodée en base64 dans un URL

The 2006-12-04 at 17:39 by Loïc d'Anterroches filed under News.

Si vous utilisez l’implémentation PHP de l’encodage en base64, cette implémentation utilise + et / comme caractères. Cela vient de me faire un joli bug dans une de mes applications. Pensez à faire une substitution avant son utilisation. Par exemple en faisant :

# Encode
$string = 'toto';
$string = base64_encode($string);
$encoded = str_replace(array('+','/','='), array('-','_','.'), $string);
# Décode
$string = str_replace(array('-','_','.'), array('+','/','='), $encoded);
$string = base64_decode($string);

L’info sur le site de PHP.

Comments from readers

Voice your ideas

It is painless and I try not to kill electrons in the process.


Your email is required but will not be shared nor displayed.


Do you think your comment will force me to write even better stuff next time? If so, you simply rock.


Logo of Plume CMS