简体   繁体   中英

base64 encode string from a terminal?

OS X 10.8.3 C++

We have base64 encode and decode functions in our code.

However, I want to base64 encode a string from my terminal and use it in my code so our functions can decode it when it needs to be used.

How does one base64 encode a string from a terminal?

Using the base64 command, sensibly enough:

# echo Hello | base64
SGVsbG8K
# echo SGVsbG8K | base64 -D
Hello

From here :

base64 command is available by default on my OS X 10.9.4.

Encoding: base64 <<< string .
Decoding: base64 -D <<< string .

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