Thursday, June 28, 2012

encode from echo

Every once in a while I am caught by forgetting echo command sends a trailing new line character. Use "-n" switch every time the result of echo is piped as input data for openssl when encoding. Here is for example the difference illustrated while encoding base64 the word 'hello':
$ echo -n "hello" | openssl enc -base64
However when decoding you must not use the swtich '-n':
$ echo "aGVsbG8=" | openssl base64 -d

No comments: