Mirage Source
http://web.miragesource.net/forums/

Xor Encryption
http://web.miragesource.net/forums/viewtopic.php?f=143&t=5451
Page 1 of 1

Author:  Nean [ Fri Apr 10, 2009 3:37 am ]
Post subject:  Xor Encryption

Can someone please explain this to me? I've been screwing around w/ it, and I managed to get:

Code:
Private Sub Form_Load()
    Dim Test 1 As String
    Dim Test As String
    Test1 = 0
    Test = 1
    lblLabel1.Caption = Chr(Asc(Test)) Xor Chr(Asc(Test1))
End Sub


But I still don't really get it. How can Xor be used practically? Etc, etc. Like lets say I wanted to encrypt a password with Xor, how would I do this?

Author:  GIAKEN [ Fri Apr 10, 2009 4:28 am ]
Post subject:  Re: Xor Encryption

Code:
Public Function Encryption(CodeKey As String, DataIn As String) As String
Dim lonDataPtr As Long
Dim strDataOut As String
Dim intXOrValue1 As Integer
Dim intXOrValue2 As Integer

    For lonDataPtr = 1 To Len(DataIn)
   
        intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1))
        intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
       
        strDataOut = strDataOut + Chr$(intXOrValue1 Xor intXOrValue2)
   
    Next
   
    Encryption = strDataOut
   
End Function


Something like this:

To encrypt

Encryption("key", "somebodyspassword")

To decrypt

Encryption("key", Encryption("key", "somebodyspassword"))

To explain it better, you encrypt once to encrypt, encrypt twice to decrypt.

When the string first goes in, it encrypts it to something like 22dfs432f mixing in some ASCII characters and what-not. If the key is not right when it gets unencrypted, it will still be jumbled up and won't come out the same way it came in. For example saving a password you would have the normal string password, which you encrypt, save it, then when you load you would encrypt again (double encryption = decryption), if the password doesn't match then you know the key for the encryption was wrong or they just got the password wrong.

Any questions? I'm trying to explain this.

Author:  Dragoons Master [ Fri Apr 10, 2009 4:28 am ]
Post subject:  Re: Xor Encryption

http://en.wikipedia.org/wiki/XOR_cipher

Author:  Asrrin29 [ Fri Apr 10, 2009 4:52 am ]
Post subject:  Re: Xor Encryption

I use the AES class from 3.0.7 to encrypt/decrypt. works very well imo.

Author:  Nean [ Fri Apr 10, 2009 5:04 am ]
Post subject:  Re: Xor Encryption

Thanks for the help guys. I think I can manage this. I just need to look over the function and dissect it so that I can get a better understanding, if I need any more help I'll just post here again. :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/