Encryption

shariefoo

Registered User.
Local time
Today, 21:54
Joined
Sep 29, 2003
Messages
65
Hi all,

Anyone knows the code that would encrypt a string ?? i am sure that there is such code but i totaly forgot iy ;)


Thanx ....
 
Here's a simple one:

Code:
Public Function PerformEncryption(ByRef strPassword As String, ByVal boo As Boolean) As String
    ' boo = True then Encrypt, boo = False then Decrypt
    
    Dim strCode As String, intCounter As Integer

    For intCounter = 1 To Len(strPassword)
        If intCounter Mod 2 = 0 Then
            If boo = True Then
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) + 1)
            Else
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) - 1)
            End If
        Else
            If boo = True Then
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) + 2)
            Else
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) - 2)
            End If
        End If
    Next intCounter

    PerformEncryption = strCode

End Function


To encrypt a string (MyString) call it like this:

MyString = PerformEncryption(MyString, True)


To decrypt a string (MyString) call it like this

MyString = PerformEncryption(MyString, False)
 
write your own.

a simple encription could be

chr()=chr() +1
 
Mile-O-Phile said:
Here's a simple one:

Code:
Public Function PerformEncryption(ByRef strPassword As String, ByVal boo As Boolean) As String
    ' boo = True then Encrypt, boo = False then Decrypt
    
    Dim strCode As String, intCounter As Integer

    For intCounter = 1 To Len(strPassword)
        If intCounter Mod 2 = 0 Then
            If boo = True Then
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) + 1)
            Else
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) - 1)
            End If
        Else
            If boo = True Then
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) + 2)
            Else
                strCode = strCode + Chr(Asc(Mid(UCase(strPassword), intCounter, 1)) - 2)
            End If
        End If
    Next intCounter

    PerformEncryption = strCode

End Function


To encrypt a string (MyString) call it like this:

MyString = PerformEncryption(MyString, True)


To decrypt a string (MyString) call it like this

MyString = PerformEncryption(MyString, False)


I can see a bug in your code, what happens if the chr to be encrypted is chr(255) or decrypted chr(0)
 
Shadez said:
What happens if the chr to be encrypted is chr(255) or decrypted chr(0)

It doesn't. ;)

I use it for passwords which are verified before they are sent for encryption.
 
The attached example uses vigenere encryption. I modified the original code because it used the character set and returned loads of strange characters. Now it only returns the characters you specify.


As an aside, I also had to make two routines out of one, the original routine used Xor so that you only needed one routine for encryption and decryption but I don’t know how to make it work as one routine with the Xor operator. Anyone like to advise me?
 

Attachments

People i cant say how thankful i am ..

THANK YOU ALL..

you guys made my life easier ;)

Cheers
 
I have stored some password, that are encrypted whith this encryption in a table. How can I make a query, out of this table, that shows the original password?
I want to be able to make a report that is able to print all passwords in a list.
 

Users who are viewing this thread

Back
Top Bottom