6

Because I am setting up vnc server, I need to convert string to base64 to setup password. (How to setup vnc password

Say, if I want my password to be qwerty, I have to place the encoded string into the password into conf file.

I see there is a base64 utility in Ubuntu. man base64. echo qwerty | base64 gives cXdlcnR5Cg==. But this doesn't work.

But if I use the online base 64 tool. qwerty is encoded to cXdlcnR5. This string WILL WORK.

Question: why the two base64 encode gives different result?

user8328365
  • 330
  • 2
  • 6
  • Possible duplicate of [Why does base64 encoding require padding if the input length is not divisible by 3?](https://stackoverflow.com/q/4080988/608639), [How to echo out things without a newline?](https://stackoverflow.com/q/38021348/608639), etc. – jww Oct 08 '18 at 00:16

1 Answers1

17

echo adds a '\n' ; try echo -n

$ echo -n qwerty | base64 
cXdlcnR5
OznOg
  • 4,440
  • 2
  • 26
  • 35