How to Encrypt a String

How to Encrypt a String

Anonymous
Not applicable
572 Views
6 Replies
Message 1 of 7

How to Encrypt a String

Anonymous
Not applicable
Hi, I'm wondering how to encrypt a string. Anybody has a clue, please help. thanks.
0 Likes
573 Views
6 Replies
Replies (6)
Message 2 of 7

arcticad
Advisor
Advisor
http://www.vbforums.com/showthread.php?t=345183

Public Function encrypt(strInput As String)
Dim n As Integer, i As Integer
n = 13
For i = 1 To Len(strInput)
Mid(strInput, i, 1) = Chr(Asc(Mid(strInput, i, 1)) + n)
Next i
encrypt = strInput
End Function


Public Function decrypt(strInput As String)
Dim n As Integer, i As Integer
n = 13
For i = 1 To Len(strInput)
Mid(strInput, i, 1) = Chr(Asc(Mid(strInput, i, 1)) - n)
Next i
decrypt = strInput
End Function
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 7

Ed__Jobe
Mentor
Mentor
It depends on how secure you need it, but basically you apply an algorithm to the text, chaning it into some other string. You need to reverse the process to decrypt it. Here's a sample. http://vbnet.mvps.org/code/algorithms/rot39.htm

The main consideration becomes, which algorithm to use. You could check msdn for more info.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 4 of 7

Ed__Jobe
Mentor
Mentor
That looks like ROT-13.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 7

Anonymous
Not applicable
Hi, Everybody, Thank you for your replies, and Sorry I didn't reply promptly. I'm just curious, why use Rot-13, not Rot-14 or something, is there any limitation on the number?
0 Likes
Message 6 of 7

arcticad
Advisor
Advisor
There are 26 letters. So half of them is 13. It's so you can always easily convert them back.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 7 of 7

Ed__Jobe
Mentor
Mentor
You are only limited by your imagination as to what algorithm you apply to encrypt something. As I said earlier, what level of security you need would determine to what level of encryption you need. If you are just trying to discourage a fellow employee, then you could get away with low security. But if your information is exposed to the internet where there are people with nothing better to do than to hack into things, then you need more security. As to ROT-13, some patterns are easily recognizable.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes