Convert Ascii to Binary (BASH)

Simple one liner to dump an Ascii string out in binary

Details

  • Language: BASH

Snippet

echo $MESSAGE | perl -lpe '$_=unpack"B*",$_'

# To convert back
echo $BINARY | perl -lpe '$_=pack"B*",$_'

Usage Example

$ echo Hello World | perl -lpe '$_=unpack"B*",$_'
0100100001100101011011000110110001101111001000000101011101101111011100100110110001100100

$ echo 0100100001100101011011000110110001101111001000000101011101101111011100100110110001100100 | perl -lpe '$_=pack"B*",$_'
Hello World