Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I encrypted a password using this code, and now I don't know how to decrypt it again. Please help me out...

VB
Public Function SimpleCrypt1( _
    ByVal encrypt As String) As String
       ' Encrypts/decrypts the passed string using
       ' a simple ASCII value-swapping algorithm
       Dim strTempChar As String, i As Integer
       For i = 1 To Len(Text)
           If Asc(Mid$(Text, i, 1)) < 128 Then
               strTempChar = _
         CType(Asc(Mid$(Text, i, 1)) + 128, String)
           ElseIf Asc(Mid$(Text, i, 1)) > 128 Then
               strTempChar = _
         CType(Asc(Mid$(Text, i, 1)) - 128, String)
           End If
           Mid$(Text, i, 1) = _
               Chr(CType(strTempChar, Integer))
       Next i
       Return Text
   End Function
Posted
Updated 3-Jun-10 4:17am
v2
Comments
Johnny J. 3-Jun-10 10:07am    
Why didn't you post this code right away in your original thread - then you could have gotten a much quicker answer?

Plus there would have been one coherent post for people to browse - not two incoherent as there are now...

Sauro is right - it even says so in the code comment.

Just a comment: This is not a very safe encryption. I don't know what your safety requirements are, but you might want to have a look at the functionality that exists in the System.Security.Cryptography namespace.

Here's a very good article for you:

The Art & Science of Storing Passwords[^]
 
Share this answer
 
This is a trivial algorythm! Simply use it again on the "encripted" text to get back the original one.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900