Why openssl and base64 return a different result?

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

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


What's the matter? How?
March 19th 20 at 08:26
1 answer
March 19th 20 at 08:28
Solution
Because you submitted them to different strings.
Remove -n and the result will be the same.

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

$ echo 'hello' | base64
aGVsbG8K
Yes, but why online encoders give the result that with this flag? https://www.base64encode.org/

Isn't it more correct? What's the difference anyway? - Emmett65 commented on March 19th 20 at 08:31
The difference in the presence or absence at the end of the newline.

In the rest of openssl and base64 and just base64 encode the command is exactly the same. - bud.Langworth6 commented on March 19th 20 at 08:34

Find more questions by tags Character encodingLinux