Mirage Source

Free ORPG making software.
It is currently Tue Feb 03, 2026 10:37 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Xor Encryption
PostPosted: Fri Apr 10, 2009 3:37 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: [email protected]
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?

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: Xor Encryption
PostPosted: Fri Apr 10, 2009 4:28 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: [email protected]
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.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Last edited by GIAKEN on Fri Apr 10, 2009 4:29 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Xor Encryption
PostPosted: Fri Apr 10, 2009 4:28 am 
Offline
Pro
User avatar

Joined: Mon May 29, 2006 3:26 pm
Posts: 493
Location: São Paulo, Brasil
Google Talk: [email protected]
http://en.wikipedia.org/wiki/XOR_cipher

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
 Post subject: Re: Xor Encryption
PostPosted: Fri Apr 10, 2009 4:52 am 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: [email protected]
I use the AES class from 3.0.7 to encrypt/decrypt. works very well imo.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Xor Encryption
PostPosted: Fri Apr 10, 2009 5:04 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: [email protected]
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. :)

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group