feat: update base64 version

This commit is contained in:
2023-08-26 12:02:45 +08:00
parent 2ada122834
commit 1698e2d9f8
12 changed files with 47 additions and 24 deletions

View File

@@ -1,3 +1,5 @@
use crate::util::base64_encode;
pub fn with_sign(mut vec: Vec<u8>) -> Vec<u8> {
if vec.len() > 0 && vec[0] >= 128 {
vec.insert(0, 0x00);
@@ -10,7 +12,7 @@ pub fn generate_ssh_string(e: &[u8], n: &[u8], comment: &str) -> String {
append_slice_with_len(&mut ssh_key, "ssh-rsa".as_bytes());
append_slice_with_len(&mut ssh_key, &with_sign(e.to_vec()));
append_slice_with_len(&mut ssh_key, &with_sign(n.to_vec()));
format!("ssh-rsa {} {}", base64::encode(&ssh_key), comment)
format!("ssh-rsa {} {}", base64_encode(&ssh_key), comment)
}
pub fn append_slice_with_len(v: &mut Vec<u8>, s: &[u8]) {