On Linux I can use the command "base64" to encode a string or "python -m base64 -e". They had the same output, but inside of the Python shell, when I use the base64, I had a different output.
#Linux prompt
Command : echo 'HelloWorld' | base64
Output : SGVsbG9Xb3JsZAo=
Command : echo 'HelloWorld' | python -m base64 -e
Output : SGVsbG9Xb3JsZAo=
--== inside of the Python shell ==--
import base64
word = "HelloWorld".encode()
new_word = base64.b64encode(word)
print(word)
print(new_word)
Output:
b'HelloWord'
b'SGVsbG9Xb3JsZA=='
What can I do? And why this is happening?
Why that happens:
Because the echo puts " \n " at the end of the string.
You forgot that echo outputs a newline.
$ echo -n 'HelloWorld' | base64
SGVsbG9Xb3JsZA==
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With