Hello all,
Currently building a little command-line tool, that will encode/decode strings in base64. Using the Base64 crate, the encode/decode functionality works fantastic out of the box. But how can I decode a base64 string completely to ASCII text? Currently it passes me back a Vec, and I have researched online a couple different ways, but all I can get is the base64 data wrapped in quotesXD.
Here is output from my terminal:
C:\Users\XXXXX\IdeaProjects\Rust\XXXX[master +4 ~0 -0 | +0 ~3 -0 !]> cargo run -- fb 'aGVsbG8gd29ybGQ='
Compiling XXXXv0.1.0 (C:\Users\XXXX\IdeaProjects\Rust\XXXX)
Finished dev [unoptimized + debuginfo] target(s) in 0.34s
Running `target\debug\XXXX.exe fb aGVsbG8gd29ybGQ=`
[104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
C:\Users\XXXX\IdeaProjects\Rust\XXXXX[master +4 ~0 -0 | +0 ~3 -0 !]> cargo run -- fb 'aGVsbG8gd29ybGQ='
Compiling XXXXXv0.1.0 (C:\Users\XXXXXX\IdeaProjects\Rust\XXXXX)
Finished dev [unoptimized + debuginfo] target(s) in 0.33s
Running `target\debug\XXXX.exe fb aGVsbG8gd29ybGQ=`
"aGVsbG8gd29ybGQ="
The first output is the basic usage of the result of decoding using the packages function. The second is the result of saving the decode functions parameters as a vec and then attempting to use the encode function to take the vec and print out the ASCII characters. Probably not doing this correct XD, any help would be greatly appreciate it. The end goal is I want to pass a base64 encoded string, and get the ASCII representation of that data, for example, the base64 encoded data in the above outputs is "hello world". I want to get "hello world" back if I pass the encoded string to the tool.
Here is code for this particular part:
let data = &decode(_command.parameters).unwrap()[..];
println!("{:?}", encode(&data));
Appreciate you all