feat: v0.3.6, add generate aes(128,192,256 bit) datakey
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use base64::Engine;
|
||||
use hyper::StatusCode;
|
||||
use josekit::jwk::alg::rsa::RsaKeyPair;
|
||||
use rusqlite::Connection;
|
||||
@@ -74,6 +74,14 @@ impl MultipleViewValue {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_without_value(v: &[u8]) -> Self {
|
||||
Self {
|
||||
value: None,
|
||||
value_hex: Some(hex::encode(v)),
|
||||
value_base64: Some(STANDARD.encode(v)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> XResult<Vec<u8>> {
|
||||
if let Some(v) = &self.value {
|
||||
Ok(v.as_bytes().to_vec())
|
||||
@@ -103,8 +111,12 @@ pub fn get_master_key() -> Option<SecBytes> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn byte_to_multi_view_map(bytes: &[u8]) -> Map<String, Value> {
|
||||
let v = MultipleViewValue::from(bytes);
|
||||
pub fn byte_to_multi_view_map(bytes: &[u8], with_value: bool) -> Map<String, Value> {
|
||||
let v = if with_value {
|
||||
MultipleViewValue::from(bytes)
|
||||
} else {
|
||||
MultipleViewValue::from_without_value(bytes)
|
||||
};
|
||||
let mut map = Map::new();
|
||||
if let Some(v) = &v.value {
|
||||
map.insert("value".to_string(), Value::String(v.to_string()));
|
||||
|
||||
Reference in New Issue
Block a user