J
J
jeruthadam2019-03-25 12:01:01
linux
jeruthadam, 2019-03-25 12:01:01

Why does openssl and base64 produce different results?

I want to encode to base64 in the console. Found 2 ways, using openssl and using base64. But they give different results!

echo -n 'hello' | openssl base64 // aGVsbG8=
base64 <<< 'hello' // aGVsbG8K

What's the matter? How right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2019-03-25
@jeruthadam

Because you are passing them different strings.
Remove -n and the result will be the same.

$ echo 'hello' | openssl base64 
aGVsbG8K
$ base64 <<< 'hello'
aGVsbG8K

$ echo 'hello' | base64
aGVsbG8K

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question