Closed RickSKy closed 1 year ago
Can you be more specific about "it failed"?
rust to generate base64 text
fn main() {
let hello = "hello";
let encoded = general_purpose::STANDARD.encode(hello);
std::fs::write("base64.txt", encoded).unwrap();
}
base64.txt data is "aGVsbG8=" then use openssl command to decode
$ /usr/bin/openssl base64 -in base64.txt -d -v -out data.txt
bufsize=8192
bytes read : 8
bytes written: 0
the decoded data is none
This is a problem with openssl base64, not this crate.
OpenSSL base64 subcommand produces nothing:
% echo -n 'aGVsbG8=' | openssl base64 -d
Top level base64:
% echo -n 'aGVsbG8=' | base64 -d
hello
Example CLI in this repo:
% echo -n 'aGVsbG8=' | cargo run --example base64 -- --decode
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
Running `target/debug/examples/base64 --decode`
hello
'/usr/bin/openssl base64' can crate base64 string. And I try to use '/usr/bin/openssl base64 -d ' to decode the message which rust-base64 generated, but it failed. I have tried general_purpose::STANDARD_NO_PAD , URL_SAFE_NO_PAD, STANDARD, URL_SAFE. Thanks