Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

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.
0
vblogic
Asked:
vblogic
1 Solution
 
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
 
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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now