引入依赖 aes = "0.7.4" block-modes = "0.8.1" hex-literal = "0.2.1"
如何将加密的数字数组转为字符串?
将字符串转换为数字数组: let plaintext = b"Hello world!"; 这个转换为数字数组
1
共 4 条评论, 1 页
引入依赖 aes = "0.7.4" block-modes = "0.8.1" hex-literal = "0.2.1"
如何将加密的数字数组转为字符串?
将字符串转换为数字数组: let plaintext = b"Hello world!"; 这个转换为数字数组
评论区
写评论https://github.com/shadowsocks/crypto2/tree/dev/src/blockcipher/aes
--
👇
hbgjh: C#语言应用有使用aes加密和解密,期待rust源码aes加密和解密
C#语言应用有使用aes加密和解密,期待rust源码aes加密和解密
use std::fmt::Write; let ciphertext = 使用aes加密后的u8数组对象;
let mut signature_string = String::new(); for a in ciphertext.iter() { write!(signature_string, "{:02x}", a); }
亲测有效
对应的crate为hex
assert_eq!(hex::encode("Hello world!"), "48656c6c6f20776f726c6421"); assert_eq!(hex::encode(vec![1, 2, 3, 15, 16]), "0102030f10");
如果想要大写的串,用encode_upper代替encode