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
https://forums.phpfreaks.com/topic/186443-hackable/
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
https://forums.phpfreaks.com/topic/186443-hackable/#findComment-984548
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.