I am looking for some easy way in shell script for converting hex number into sequence of 0 and 1 characters.
Example:
5F -> "01011111"
Is there any command or easy method for accomplish it or should I write some switch for it?
I am looking for some easy way in shell script for converting hex number into sequence of 0 and 1 characters.
Example:
5F -> "01011111"
Is there any command or easy method for accomplish it or should I write some switch for it?
I used 'bc' command in Linux. (much more complex calculator than converting!)
ibase parameter is the input base (hexa in this case), and obase the output base (binary).
Hope it helps.
Perl’s
printf
already knows binary:I wrote https://github.com/tehmoon/cryptocli for those kind of jobs.
Here's an example:
Yields:
The opposite also works.
NB: It's not perfect and much work needs to be done but it is working.
Or
i
command will pop the top of the stack and use it for the input base.Hex
digits must be in upper case to avoid collisions with dc commands and are not limited toA-F
if the input radix is larger than16
.o
command does the same for the output base.p
command will print the top of the stack with a newline after it.