Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Encryption 1997-11-19 -- Kurt Paulikowski One of the easiest and arguably most common encryption methods is to use an
"exclusive or" (bxor). Not really high security, but it'll keep out most... It works something
like this...
loc:Data cstring(100)
loc:EncryptionKey cstring(20)
1 loc:EncryptionKey = 'Whatever You Want'
2 j# = 0
3 loop i# = 1 to len(Data)
4 j# += 1
5 if j# > len(loc:EncryptionKey) then j# = 1.
6 loc:Data[i#] = bxor(loc:Data[i#],loc:EncryptionKey[j#])
7 .
Notes: First, this routine has one very interesting property: it both encrypts and decrypts
your data! First, cstrings are used so your len() function is accurate (you may want to
add "loc:Data = clip(loc:Data)" and loc:EncryptionKey = clip(loc:EncryptionKey) to be
sure). Line 1 just assigns some value to use in encrypting the data. I could be anything,
but, of course, has to be the same each time you run it. The loop (lines 3/7) steps
through the data, and XOR's it with a byte from the encryption key (line 7). Lines 4 and
5 just step through the key. It's simple and relatively effective. Not recommended for
government secrets though!
Today is November 21, 2024, 7:39 am This article has been viewed 35204 times.
|
|