Lasso Soft Inc. > Home

[lp_crypt_xor]

Linklp_crypt_xor
AuthorBil Corry
CategoryEncryption
Version8.x
LicensePublic Domain
Posted21 Apr 2006
Updated21 Apr 2006
More by this author...

Description

Returns xor-encrypted/decrypted string given a string and password.

Requires [lp_array_roundrobin] [lp_string_asc] [lp_string_chr]

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);

'
';
'Encrypted = ' $encrypted_text '\r\n';
'Decrypted = ' $decrypted_text '\r\n';
'
';

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.

[

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

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft