Search code examples
vb6encodingbase64encodebase32

Encrypt printable text so result is still printable (can be typed)


I want to encrypt some info for a licensing system and I want the result to be able to be typed in by the user.

Update: This operation must be reversible (decrypt-able) E.g., Encrypt ( ComputerID+ProductID) -> (any standard ASCII character that can be typed. Ideally maybe even just A-Z).

So far what I did was to convert the encrypted text to HEX (so it's any character from 0-F) but that doubles the number of characters.

I'm using VB6.

I'm thinking I'd do some operation on each pair of (Input$(x) and Key$(x)) and then do a MOD to keep it within a range of ascii values (maybe 0-9-A-Z)

Any suggestions of a good algorithm?


Solution

  • Look into Base64 "encryption."

    Base 64 will convert a number into 64 different ASCII characters, verses hex which is only 16 different ASCII characters... Making Base64 more compact and what you are looking for.

    EDIT: Code to do this in VB6 is available here: http://www.nonhostile.com/howto-encode-decode-base64-vb6.asp

    Per Fuzzy Lollipop, below, Base32 looks like an even better option. Bonus points if you can find an example of that.

    EDIT: I found an example of Base32 for VB6 although I've not tried it yet. -Clay