If you just want to save some information, but โencodeโ it using the character set you used above (0-9A-Z), you can use the algorithm below.
The code is an old Python program (3). This, of course, does not look like anything, and is not very verified, but I think it is better than nothing, since you do not have many answers yet. Simply transfer the code to PHP or AS. The reduce statements can be replaced, for example, by imperative style styles. Also note that // stands for integer division in Python.
It should also be fairly easy to apply some compression / encryption to it. Hope it looks like what you wanted. Here it goes.
from functools import reduce class Coder: def __init__(self, alphabet=None, groups=4): if not alphabet: alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" self.alphabet = alphabet self.groups = groups def encode(self, txt): N = len(self.alphabet) num = reduce(lambda x,y: (x*256)+y, map(ord, txt))
Output Example:
Encoded: D1RD-YU0C-5NVG-5XL8-7620 Decoded: Hello world!
source share