I'd like to encode certain information, such as date and time of build and the SVN revision, into a reversible alphanumeric string so I can easily identify a build (besides maintaining a table of known builds).
I have no idea of how to go about this. Can you point me to related algorithms, commands, etc that will help me with this?
If you don’t need it to be too too short, use Base64 encoding.
$ echo $(date +%s)-r3749 | base64
MTM1ODg4MzA3MS1yMzc0OQo=
$ echo MTM1ODg4MzA3MS1yMzc0OQo= | base64 --decode
1358883071-r3749
Here I used an Epoch time since it’s fewer characters than a full date. Since it’s a number, and the SVN revision is a number too, you could also encode them using a different base. Using this Base 62 encoding function, you could reversibly encode the (date, revision) pair 1358883071-r3749
as 1tXJyT,Yt
But Base64 is probably short enough, and it’s super easy.