Needed a function that encrypt/decrypt a password. 
Author Message
 Needed a function that encrypt/decrypt a password.

Hello I'm looking for a quick function that encrypt/decrypt a password.
I don't need something too fancy.

If you could give me a sample code it would be great!

Thanks...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl-G?ran Bolinder



Wed, 18 Jun 1902 08:00:00 GMT  
 Needed a function that encrypt/decrypt a password.

Quote:
> Hello I'm looking for a quick function that encrypt/decrypt a password.
> I don't need something too fancy.

Public Function Encrypt(Password As String) As String
    Dim iCounter As Integer
    Dim iLoop As Integer
    Dim iRandom As Integer

    Rnd -1
    Randomize 1
    Encrypt = ""

    For iCounter = 1 To Len(Password)
        For iLoop = 1 To Asc(Mid(Password, iCounter, 1))
            iRandom = Int(Rnd * 128) + 32
        Next iLoop

        Encrypt = Encrypt & Chr$(iRandom)
    Next iCounter
End Function

To save a password, use something like this:

    database.field = encrypt(txtPassword.text)

To verify that a user has typed in the correct password, do this:

    if database.field = encrypt(txtPassword.text) then 'it's a match

Scott



Wed, 18 Jun 1902 08:00:00 GMT  
 Needed a function that encrypt/decrypt a password.
Thanks Scott, works Great! its exactly what I was looking for.


Quote:


> > Hello I'm looking for a quick function that encrypt/decrypt a password.
> > I don't need something too fancy.

> Public Function Encrypt(Password As String) As String
>     Dim iCounter As Integer
>     Dim iLoop As Integer
>     Dim iRandom As Integer

>     Rnd -1
>     Randomize 1
>     Encrypt = ""

>     For iCounter = 1 To Len(Password)
>         For iLoop = 1 To Asc(Mid(Password, iCounter, 1))
>             iRandom = Int(Rnd * 128) + 32
>         Next iLoop

>         Encrypt = Encrypt & Chr$(iRandom)
>     Next iCounter
> End Function

> To save a password, use something like this:

>     database.field = encrypt(txtPassword.text)

> To verify that a user has typed in the correct password, do this:

>     if database.field = encrypt(txtPassword.text) then 'it's a match

> Scott



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Encrypting/Decrypting passwords for registry use?

2. encrypt/decrypt password in vbscript

3. Password encrypt/decrypt

4. password encrypt and decrypt

5. Encrypting/Decrypting passwords for registry use?

6. Security: Encrypt and Decrypt an external text file

7. Repost: encrypt/decrypt image data

8. Repost: encrypt/decrypt binary image data

9. Encrypting / Decrypting Strings

10. encrypt decrypt string

11. NEWBIE > Encrypt/Decrypting

12. How to encrypt and decrypt strings?

 

 
Powered by phpBB® Forum Software