drisate Posted June 13, 2011 Share Posted June 13, 2011 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 More sharing options...
drisate Posted June 13, 2011 Author Share Posted June 13, 2011 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> Link to comment https://forums.phpfreaks.com/topic/239295-hex-numbers-to-ascii/#findComment-1229342 Share on other sites More sharing options...
xyph Posted June 14, 2011 Share Posted June 14, 2011 That is not a hex string Hex strings will be 0-9,A-F Link to comment https://forums.phpfreaks.com/topic/239295-hex-numbers-to-ascii/#findComment-1229347 Share on other sites More sharing options...
requinix Posted June 14, 2011 Share Posted June 14, 2011 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; } Link to comment https://forums.phpfreaks.com/topic/239295-hex-numbers-to-ascii/#findComment-1229350 Share on other sites More sharing options...
drisate Posted June 14, 2011 Author Share Posted June 14, 2011 Ths it's not working but thats the start i needed to get the rest done =) thank you very much! Link to comment https://forums.phpfreaks.com/topic/239295-hex-numbers-to-ascii/#findComment-1229355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.