Password Decrypte
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Password Decrypte

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    159

    Password Decrypte

    Hi, I has the following codes to encrypte the password user enter:

    Code:
        Public Function fnEncrypt(ByVal sString As String, ByVal lLEn As Long) As String
            Dim I As Long
            Dim NewChar As Long
            I = 1
            Do Until I = lLEn + 1
                NewChar = Asc(Mid(sString, I, 1))
                NewChar = ((NewChar - 32 + 13) Mod 95) + 32     'avaible keyboard from ASCII 32 to 126
                fnEncrypt = fnEncrypt + Chr(NewChar)
                I = I + 1
            Loop
            Return fnEncrypt
        End Function
    For eg. User enter 123456, the password will be encrypte become >?@ABC.

    How can I write my codes to decode it from >?@ABC become 123456?

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Password Decrypte

    subtract 32
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2009
    Posts
    159

    Re: Password Decrypte

    Hi, I tried but it won't works..

  4. #4
    Join Date
    Jan 2009
    Posts
    159

    Re: Password Decrypte

    Hi, sorry that I can't get what you means.

  5. #5
    Join Date
    Aug 2009
    Location
    NW USA
    Posts
    173

    Re: Password Decrypte

    All of the gyrations are essentially shifting the character right 13. To decrypt you need to subtract 13 from the ASCII of the character. If this is less than 32 then add 95.

    I don't think the code will work. The "fnEncrypt = fnEncrypt . . . " will probably recursively (and incorrectly) call the function again. You should use a local variable to hold your string.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center