I need to communicate between Javascript and PHP (I use jQuery for AJAX), but the output of the PHP script may contain binary data. That\'s why I use bin2hex()
bin2hex()
If someone needs the other direction (bin to hex), here is it:
function bin2hex(bin) { return new Buffer(bin).toString("hex"); }