Simple Encryption?

Does anyone have an encryption routine that can take any string and encrypt it into a string that contains only numbers and capital letters (e.g., DHSK3J641GA)

I do not want to use a Hex representation because these strings may be somewhat long and a Hex representation will only make it longer.  The encrypted string will be given to customers over the phone so I need to avoid complex strings with lower-uppercase issues and any special characters.  This is for licensing an application.  The encrypted string will contain information used by the program.
LVL 1
vblogicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JacamarCommented:
This will prevent lowercase letters from being typed in the textbox.


Dim fBoolChange As Boolean
Dim inI As Integer

Private Sub Text1_Change()
If fBoolChange = True Then
    fBoolChange = False
    Text1.Text = Replace(Text1.Text, Chr(inI), Chr(inI - 32))
    Text1.SelStart = Len(Text1.Text)
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > 96 And KeyAscii < 123 Then
    fBoolChange = True
    inI = KeyAscii
End If
End Sub
0
JacamarCommented:
Here is a command that will do it.  Just get your string in to ststring, and it will do the rest

Private Sub Command1_Click()
Dim ststring As String
Dim inI As Integer
Dim inKeyasc As Integer

ststring = CStr(Text1.Text)

inI = Len(ststring)

For i = 1 To inI
    inKeyasc = Asc(Mid(ststring, i, 1))
    If inKeyasc > 96 And inKeyasc < 123 Then
            inKeyasc = inKeyasc - 32
            Mid(ststring, i, 1) = Replace(Mid(ststring, i, 1), Chr(inKeyasc + 32), Chr(inKeyasc))
    End If
   Next i

Text1.Text = ststring
End Sub
0
AzraSoundCommented:
How is this at all related to the question which is about encryption?  Encryption being altering data into an unrecognizable format.  For explanation purposes only:

Prior to Encryption :  "Hello World"
After Encryption :  "DHA249FHSU9"

Then, you should be able to run the 'After Encryption' string through a decryption routine to receive the data string value 'Prior to Encryption'.
0
SteinerCommented:
Well, the problem with the length: you'll have to remember that the encrypted string has to be longer than the original one since you can only use fewer charaters.

While in the original string you can have brackets, lower case and special characters, in the encrypted one you can't. So you'll have to replace at least some characters by 2 characters in the encrypted string (I'd guess 2 third, and since you would have to differ between 2 encrypted chars = 1 decrypted char and 1 encrypted char= 1 decrypted char, that amount will surely increase further).

So I think your hex-approach wouldn't be the worst thing since it's easy to convert (maybe some addition to confuse the user...) and should be fairly easy to revert to the original text, too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Arthur_WoodCommented:
as Steiner has said, your original request:

"Does anyone have an encryption routine that can take any string and encrypt it into a string that contains only numbers and capital letters (e.g., DHSK3J641GA)"

CANNOT be accomplished easily.  To be specific (to elaborate on steiner's explanation)-->  "He" and "hE",for examp must be Encrypted to DIFFERENT result strings, but since you are only allowing UPPER CASE letters and NUMBERS, the RESULT set im LIMITED to a maximum of 36 different characters, which the SOURCE string can be from a set of AT LEAST 62 characters (26 Upper case letters, 26 Lower case letters, 10 digits, blanks, as well as other possible non-alphanumeric characters (;,./[]()*&^%$#@! etc))

I suggest you re-think the original request.

AW
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.