1
0
This commit is contained in:
2025-06-20 11:23:21 +08:00
commit b5601aef8c
47 changed files with 1829 additions and 0 deletions

13
problems/p1/src/main.rs Normal file
View File

@@ -0,0 +1,13 @@
use base64::{Engine as _, engine::general_purpose::STANDARD};
fn hex_to_base64(hex_str: &str) -> String {
let bytes = hex::decode(hex_str).expect("解码失败");
STANDARD.encode(&bytes)
}
fn main() {
// 从十六进制字符串解码为原始字节
let hex_str = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let base64_str = hex_to_base64(hex_str);
println!("十六进制字符串: {}", base64_str);
}