binary sed replacement

bbe is a “sed for binary files”, and should work more efficiently for large binary files than hexdumping/reconstructing. An example of its use: $ bbe -e ‘s/original/replaced/’ infile > outfile Further information on the man page.

bash ascii to hex

$ str=”hello” $ hex=”$(printf ‘%s’ “$str” | xxd -p -u)” $ echo “$hex” 68656C6C6F Or: $ hex=”$(printf ‘%s’ “$str” | hexdump -ve ‘/1 “%02X”‘)” $ echo “$hex” 68656C6C6F Careful with the ‘”%X”‘; it has both single quotes and double quotes.

Java: convert a byte array to a hex string?

From the discussion here, and especially this answer, this is the function I currently use: private static final char[] HEX_ARRAY = “0123456789ABCDEF”.toCharArray(); public static String bytesToHex(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = … Read more

How to convert hex string into a bytes array, and a bytes array in the hex string?

Convert a hex string to a byte array and vice versa note: implementation from crypto-js, though now out of date and slightly altered // Convert a hex string to a byte array function hexToBytes(hex) { let bytes = []; for (let c = 0; c < hex.length; c += 2) bytes.push(parseInt(hex.substr(c, 2), 16)); return bytes; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)