Anyone have a good simple encryption/decrpytion function?
to encrypt/decrypt a string?
nothing fancy, just one that will work 100% and return characters that can be seen in a textbox.. (there are some functions that return really high ascii characters that are 'boxes' in textboxes... and if one was to copy that to a text file, then decrypt the data in the text file, the boxes would all decrpyt to a single character, since they all have the same ascii code)
Re: Anyone have a good simple encryption/decrpytion function?
Do a search of the forums. There are many examples as the subject comes up every week. You can also search in the CodeBank, for complete solutions.
If you want simple encryption, you could just loop through the textbox character by character. For each character, take the x=ASC() number of the key, and add a nother number to it (say 2). Then change the character to z=chr(x+2)
This would change David into Fcxkf. Then to decrypt, just reverse the process to get David.
Function Decrypt(sText As String, sKey As String) As String
Dim x As Long, i As Long, k As Long
For i = 1 To Len(sText)
k = k + 1
x = Asc(Mid(sText, i, 1)) Xor Asc(Mid(sKey, k, 1))
If x > 20 Then Decrypt = Decrypt & Chr(x) ''bcoz we know upto 20 is fake chars
If k >= Len(sKey) Then k = 1
Next
End Function
Pradeep
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering
I bet u need a fusion powered shuttle to reach my place...
Posts
963
Re: Anyone have a good simple encryption/decrpytion function?
Check out google.
Look for BlowFish, or something like that.
There's VB example source codes for it, and the encryption is pretty strong.
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline
So I consider all those working engineers sad people
Re: Anyone have a good simple encryption/decrpytion function?
Here's an example of MD5 encryption.
This class also does other encryption like URL Encoding this MD5 encrypted data, which is handy.
I use this is what I use in my apps. just run Data Encryption.vpg
There is also another demo in this zip that allows you to encypt file.