Research, development and trades concerning the powerful Proxmark3 device.
Remember; sharing is caring. Bring something back to the community.
"Learn the tools of the trade the hard way." +Fravia
You are not logged in.
Time changes and with it the technology
Proxmark3 @ discord
Users of this forum, please be aware that information stored on this site is not private.
Hi,
I doesn't found a tool to manipulate long binary string (or hex) so I define some alias
you need to have bc installed.
create a file binconv.sh with the following
function bin2hex() {
echo "ibase=2;obase=10000;$1" | bc
}function dec2hex() {
echo "ibase=10;obase=16;$1" | bc
}function hex2bin() {
STR=echo $1 | tr '[a-f]' '[A-F]'
echo "ibase=16;obase=2;$STR" | bc
}function hex2dec() {
STR=echo $1 | tr '[a-f]' '[A-F]'
echo "ibase=16;obase=A;$STR" | bc
}function hex2str() {
I=0
STR=$1
while [ $I -lt ${#STR} ];
do
echo -en "\x"${STR:$I:2}
let "I += 2"
done
}alias bin2hex=bin2hex
alias hex2bin=hex2bin
alias dec2hex=dec2hex
alias hex2dec=hex2dec
alias hex2str=hex2str
then source the file
. binconv.sh
now, you can use converter like this
like :
bin2hex 11111111111110100001110000000000111110011010100010101010111100100100110111000000101000010001001011111000110000100001000000000110
FFFA1C00F9A8AAF24DC0A112F8C21006
hex2bin FFFA1C00F9A8AAF24DC0A112F8C21006
11111111111110100001110000000000111110011010100010101010111100100100110111000000101000010001001011111000110000100001000000000110
update: add case convert and output to str
Have a nice day
Last edited by rbubba1911 (2015-08-01 23:07:32)
Offline
We should really build this kind of functionality into the client...
Offline
Coming right up...
proxmark3> data hex2bin deadbeef
11011110101011011011111011101111
proxmark3> data bin2hex 11011110101011011011111011101111
DEADBEEF
proxmark3> data bin2hex 1
[padded with 7 zeroes]
80
proxmark3>
Offline
however, Bin 1 -> hex 80 ?!?! I still thought that would be 01...
Offline
Hm. I didn't even consider that, it felt intuitive that zeroes were added to the right side. I saw it as a "stream of data", not as a "value". If you use it to convert "values", I understand that it feels counter-intuitive...
I would probably only use this function to convert large blobs of binary. If you have a really big blob, it feels strange that the first byte of output differs depending on if you cut'n'pasted 1023 digits instead of 1024....
Offline
I guess I've been cut 'n pasting from the calc too many times, where it takes away the leftmost zeros. Always forcing me to start in the rightmost position and figuring out how much to pad when I gone thru all numerals
Offline