VBA code to encrypt and decrypt plain text

P

Peter

I would like encrypt and decrypt information to use in a software activation
process. The software is distributed as a Word document which installs a
template in the start up folder.

The basic process is that:
* the VBA tempalate generates a 10 character computer ID
* the trial can be used for 60 days before registration
* user sends the 10 char ID to me with payment
* I send them an activation code based on the ID they send me
* they enter the activation code into the Word VBA
* if it matches a key based on the ID then the tempate is unlocked for a year

I have looked at code based on xor but the output is either non-printable
text or is twice as long which is not good for an activation code.

Can anyone point me to some sample encryption routines written in VBA where
the coded and decoded text has to
* be printable characters (preferably all upper or lowercase letters for
readability
* be reasonably short e.g. if the key is 10 chars and the decoded is 10
characters then the coded text should be 10 or up to 15 characters ... but
definitely not 20

Any assistance gratefully accepted,
PeterEvans
 
K

Karl E. Peterson

Peter said:
I would like encrypt and decrypt information to use in a software activation
process. The software is distributed as a Word document which installs a
template in the start up folder.

The basic process is that:
* the VBA tempalate generates a 10 character computer ID
* the trial can be used for 60 days before registration
* user sends the 10 char ID to me with payment
* I send them an activation code based on the ID they send me
* they enter the activation code into the Word VBA
* if it matches a key based on the ID then the tempate is unlocked for a year

You realize that the code within the template is wide-open for anyone to modify,
should they wish to sidestep your activation process, right?
I have looked at code based on xor but the output is either non-printable
text or is twice as long which is not good for an activation code.

Can anyone point me to some sample encryption routines written in VBA where
the coded and decoded text has to
* be printable characters (preferably all upper or lowercase letters for
readability
* be reasonably short e.g. if the key is 10 chars and the decoded is 10
characters then the coded text should be 10 or up to 15 characters ... but
definitely not 20

Just take the first X characters of your encoded string, and concatenate their hex
codes. Something like:

For i = 1 to X
' xord is the unprintable encoded string.
key = key & Right$("0" & Hex(Mid$(xord, i, 1)), 2)
Next i
 
P

Peter

Karl E. Peterson said:
You realize that the code within the template is wide-open for anyone to modify,
should they wish to sidestep your activation process, right?

The code is protected using a VBA project password. I'm not sure how secure
that is but perhpas others can tell me.

Peter
 
T

Tony Jollans

About as secure as a hole in the hedge. If I could be bothered I could write
some code to make it instantaneous; as it is it takes me a few seconds of
manual effort to walk through it, on the odd occasion I wish to do so.
 
K

Karl E. Peterson

Peter said:
The code is protected using a VBA project password. I'm not sure how secure
that is but perhpas others can tell me.

Tony put it rather poetically. I'd have just said, "Not at all."

I have a 20-line routine that will break any VBA project password.

Really opened the eyes of one developer, when I gave him the source to PDFWriter.

Microsoft ought to be ashamed for offering that mirage.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top