简体   繁体   English

来自终端的base64编码字符串?

[英]base64 encode string from a terminal?

OS X 10.8.3 C++ OS X 10.8.3 C++

We have base64 encode and decode functions in our code.我们的代码中有 base64 编码和解码功能。

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.但是,我想对来自终端的字符串进行 base64 编码并在我的代码中使用它,以便我们的函数可以在需要使用时对其进行解码。

How does one base64 encode a string from a terminal?一个 base64 如何编码来自终端的字符串?

Using the base64 command, sensibly enough:使用base64命令,足够明智:

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

From here :这里

base64 command is available by default on my OS X 10.9.4.默认情况下,我的 OS X 10.9.4 上可以使用 base64 命令。

Encoding: base64 <<< string .编码: base64 <<< string
Decoding: base64 -D <<< string .解码: base64 -D <<< string

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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