PYTHON bin2hex

is this article helpful?
|
Python replacement for PHP's bin2hex [ edit | history ]
#Python 2.x:
result = myStr.encode('hex')

#Function
def bin2hex(binn):
	import string
	sonuc = binn.encode('hex')
	return sonuc

#exapmle 2.x func;
print bin2hex("fatihmert")
#result -> 66617469686d657274


#Python 3.x:
import binascii
result = binascii.hexlify(data)

PHP bin2hex

PHP original manual for bin2hex [ show | php.net ]

bin2hex

(PHP 4, PHP 5)

bin2hexConvert binary data into hexadecimal representation

Description

string bin2hex ( string $str )

Returns an ASCII string containing the hexadecimal representation of str . The conversion is done byte-wise with the high-nibble first.

Parameters

str

A character.

Return Values

Returns the hexadecimal representation of the given string.

See Also

  • pack() - Pack data into binary string
  • unpack() - Unpack data from binary string