Question

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?

Was it helpful?

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

OTHER TIPS

encode the encrypted bytes in HEX, or Base32 or Base64

Do you want this to be reversible -- to recover the IDs from the encrypted text? If so then it matters how you combine the key and input strings.

Usually you'd XOR each byte pair (work with byte arrays to avoid Unicode issues), circulating on the key string if it's shorter than the input. You can then use Base N encoding (32, 64 etc) to generate the license string.

Both operations are reversible: you can recover the XORed strings from the Base N string, then XOR with the key again to get the original IDs.

If you don't care about reversing the operations, then any convolution of key and ID will do. XOR is just the simplest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top