anshu
anshu

Reputation: 665

Reading a binary file as an array of bytes or 16 or 32 bits using shell script

I am working on ARM-based modem linux host machine and I need to read a bin file as an 8-,16- or 32- bits array. I basically need to encrypt the file in question and was thinking of just XOR-ing the bits with a random bit sequence (I dont need a very complex system). The linux host doesn't have C or PERL modules in it so I cant use them and hence I need to do it using a shell script. Can anyone please give me some pointers on how to proceed with this.

Also, if someone can suggest an alternate way to do this that would certainly be useful for me as well.

Cheers, Anshu

Upvotes: 2

Views: 1389

Answers (1)

pts
pts

Reputation: 87221

Most probably it's not possible within the shell (Bash or similar), so you need an external program for that. Maybe the hexdump or od programs can do the reading for you, if they are available.

My suggestion: write a small C program for that, compile it using a cross-compiler, and run it from your shell script.

The gpg and openssl binaries can do encryption for you. I don't know how easy it is to compile or install them to your host.

Upvotes: 2

Related Questions