简体   繁体   中英

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?

Suppress the newline.

echo -n "b" | ...

Or add it.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM