Jump to content

Recommended Posts

Hey guys i need to create a php function that will decrypt a hex string that looks like this:

 

V8384FFD0CCE1B5FABBDBD6A2B584EAAEA4999B9B7A777FAA

 

should return leadplus

 

This is what i have so fare

function hex_str($hex){
    $string='';
    for ($i=0; $i < strlen($hex)-1; $i+=2){
        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
    }
    return $string;
}

 

But it's not returning the good string at all!

8OýÎ_«½½j+XNªêI™¹·§wú

 

Help would be very appreciated

Link to comment
https://forums.phpfreaks.com/topic/239295-hex-numbers-to-ascii/
Share on other sites

This si exacly what i need but i need it in PHP

<script type="text/javascript">
function wsFTP_decoder(in_string) {

	my_password = in_string.substring(37, in_string.length);
	var x = "";
	for (var i = 0; i < my_password.length / 2; i++) {
		document.forms[0].decoded_entry.value = "";
		var my_character = my_password.substring(i * 2, i * 2 + 2);
		var my_parsed = in_string.substring(5 + i, 6 + i);
		var my_clear_txt = parseInt("0x" + my_character) - i - 1 - ((47 + parseInt("0x" + my_parsed)) % 57);
		x = x + String.fromCharCode(my_clear_txt);
		document.forms[0].decoded_entry.value = x;
	}

}
</script> 

A literal translation would be

function wsFTP_decoder($in_string) {
$my_password = substr($in_string, 37);
$x = "";
for ($i = 0; $i 		//document.forms[0].decoded_entry.value = ""; // should be before the for loop
	$my_character = substr($my_password, $i * 2, $i * 2 + 2);
	$my_parsed = substr($in_string, 5 + $i, 6 + $i);
	$my_clear_txt = hexdec($my_character) - $i - 1 - ((47 + hexdec($my_parsed)) % 57);
	$x = $x . chr($my_clear_txt);
	//document.forms[0].decoded_entry.value = $x; // should be after the for loop
}

return $x;
}

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.