A data conversion utility that convert files or strings to different representations of Hexadecimal number encodings, as well as Base64, and even MD5.
It was one of my first C program written more than 10 years ago, so don't judge strictly :)
It is as simple as:
% make
Usage: str2hex [params] <string>
or: str2hex [params] '<string>'
Params:
-f <file> Read input from the file (Default is STDIN).
-o <file> Output to the file (Default is STDOU).
-q Ignore "new line" symbols.
-h This help.
-v Version.
-i [char],[char],[char]... Include to convert list only symbols "char" : ..%2f..%2fetc...
-e [char],[char],[char]... Exclude from convert list symbols "char" : %2e%2e/%2e%2e...
Conversion params:
-p Convert to "plain" hex format: 2f6574632f706173737764...
-n Convert 10-base numbers to 16-base (hex) numbers: 6323A37B327F...
-no Convert 10-base numbers to 8-base (oct) numbers: 384636424...
-m Convert to MySQL format: 0x2f6574632f706173737764... (Default)
-mc Output as MySQL CHAR format: CHAR(2f,65,74,63,2f,70)...
-c Convert to C-style oct-chars format: \3\94\94\574\545...
-ch Convert to C-style hex-chars format: \x2\x94\xE3\x32...
-cf * full printf suntax style: \"\32\322\"\n...
-cc * plain text printf suntax style: \"Lorem ipsum\"\n
-t Convert to AT&T assembler hex-chars format: 0xF5, 0xF3, 0xE9...
-tc * without commas: 0xF5 0xF3 0xE9
-tp * "plain" format: 0xF50xF30xE9...
-a Convert to Microsoft-Assembler chars format: E3h, C3h, E3h...
-ac * without commas: E3h C3h E3h...
-ap * "plain" format: E3hC3hE3h...
-u Convert to URL format: %EF%F0%E5%E2%E5%E4%21...
-x Convert to HTML hex format: loxx...
-xe Convert to HTML escape codes: ¡²©...
-xw * HTML escape codes, without semicolons: lo...
-b (-base64[=linesize] | -b64[=linesize] ) Output in Base64: YmZnYmRiZ2Q=
-bn Convert to Base64, but without newline formating.
-md5 Calculate MD5 (RFC 1321) hash: 929ae467fe43191eff23b9a0e1471d04
Exemples:
str2hex 'Lorem ipsum'
str2hex -u 'Lorem ipsum'
str2hex -b64 -f /etc/passwd
str2hex -i 1,2,3,4,5,6,7,8,9,0 12345678910
str2hex -a -e 1234567890abcde bsedtskdwnshc