[lp_crypt_xor]

Description

Link: [lp_crypt_xor]
Author: Bil Corry
Category: Encryption
Version: 8.x
License: Public Domain
Posted: Apr. 21, 2006
Updated: Jan. 01, 0001
More by this author...
Returns xor-encrypted/decrypted string given a string and password.

Requires [lp_array_roundrobin] [lp_string_asc] [lp_string_chr]

Parameters

-string string, required The string to encrypt/decrypt.
-password string, required The password to encrypt/decrypt.

Sample Usage

var:'text' = 'This is my message I want to encrypt.';
var:'password' = 'secret';
var:'encrypted_text' = (lp_crypt_xor: $text,$password);
var:'decrypted_text' = (lp_crypt_xor: $encrypted_text,$password);

'<pre>';
'Encrypted = ' $encrypted_text '\r\n';
'Decrypted = ' $decrypted_text '\r\n';
'</pre>';
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[

define_tag: 'lp_crypt_xor',
	-description='Returns xor-encrypted/decrypted string given a string and password.',
	-priority='replace',
	-required='string',
	-required='password';

	// init output
	local:'out' = string;

	// convert password for xor'ing
	local:'password_rr' = lp_array_roundrobin;
	iterate: (string: #password), local:'char';
		#password_rr->(insert: (lp_string_asc:#char));
	/iterate;
	
	// xor password against string
	local:'loop' = integer;
	local:'xor' = integer;
	iterate: (string: #string), local:'char';
		#xor = lp_string_asc:#char;
		#xor->(bitxor: #password_rr);
		#out += (lp_string_chr:#xor);
	/iterate;

	// return bytes
	return: #out;

/define_tag;

]

 

Comments

none

Email:


Password:



Newest

Most Popular