Rnet
Rnet

Reputation: 5040

Unix base64 encoding mismatch

I've been seeing some discrepancies in the base64 encoding in many utils from the unix util for ex: in java and python if I encode b I get Yg== but in unix I get Ygo= I need to use b64 from unix in java and python. How do I make them consistent?

Upvotes: 3

Views: 463

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798774

Suppress the newline.

echo -n "b" | ...

Or add it.

>>> 'b\n'.encode('base64')
'Ygo=\n'

Upvotes: 4

Related Questions