Jump to content

hackable?


canadabeeau

Recommended Posts

How hackable is this?

function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
	$char = substr($string, $i, 1);
	$keychar = substr($key, ($i % strlen($key))-1, 1);
	$char = chr(ord($char)+ord($keychar));
	$result.=$char;
}
return $result;
}
print_r(encrypt('<?php..zzzzzzzzzzz... ?>', 'mysite.com');

Link to comment
Share on other sites

How hackable is this?

function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
	$char = substr($string, $i, 1);
	$keychar = substr($key, ($i % strlen($key))-1, 1);
	$char = chr(ord($char)+ord($keychar));
	$result.=$char;
}
return $result;
}
print_r(encrypt('<?php..zzzzzzzzzzz... ?>', 'mysite.com');

 

Define what you mean. What it does, is encodes a string with a key, splitting each character up, turning it into its ASCII form, and binding it with the key and re-encoding it into the string. You may do "return base64_encode($result)" to be in a ore easily transportable format.

 

Since the end user does not know the custom encoding method, nor the key, it is presumably improbable for an attacker to retrieve the encoded string, what its original value is.

 

Gave up on writing a module? lol.. You may want to use this slightly modified code, as with what I mentioned, It's more secure and will place it in a variable (what you wanted):

function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
	$char = substr($string, $i, 1);
	$keychar = substr($key, ($i % strlen($key))-1, 1);
	$char = chr(ord($char)+ord($keychar));
	$result.=$char;
}
return base64_encode($result);
}

$php_code = '<?php echo "Secret"; ?>'; //What you want encoded, but runnable

$encoded_phpcode = encrypt($php_code, 'asdf1234'); //The actual encoded PHP, to be decoded by user

 

Note you will have to use base64_decode on the decrypt function, before it is unencoded. I'd give that it's as strong as any basic encryption, but it is unique, so more obscure to decode.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.