Potresti usare la funzione php "base64_encode" anche se non è molto sicura