Converts between bases 2..256. Each character in the input is one digit. Values of digits are specified in files specified using command line arguments, because 0 byte cannot be put into the argv.
If some number of digits in one base directly corresponds to some other number
of digits in the other base, baseconvert processes the input in groups of
that many characters. For example, 1111
in base 2 means F
in hex, no
matter which group it is. List of such pairs is in shortcuts.txt
.
Convert a simple number from decimal to hexademical:
$ echo -n 15 | ./baseconvert decimal.txt hex.txt && echo
f
Get the raw bytes of a hash value:
$ sha512sum important.txt | cut -d ' ' -f1 | tr -d '\n' | ./baseconvert hex.txt bytes.txt > rawhash
Bases are defined in text files of digits in their actual ordering. The first character means 0, the second means 1 and so on. All characters in the file are considered to be digits, so you probably want to remove the newline at the end. One easy way to do it is:
cat origbase.txt | tr -d '\n' > correctbase.txt
(The wheels not reinvented this time)
- Add padding or newlines to output
- Process padding or newlines in input
- Read input from a file