mirror of
https://git.um-react.app/um/lib_um_crypto_rust.git
synced 2026-03-08 04:29:54 +00:00
[qtfm] feat #4: implement QingTingFM decipher
This commit is contained in:
@@ -9,6 +9,12 @@ pub const ENGINE: Base64Engine = Base64Engine::new(
|
||||
GeneralPurposeConfig::new().with_decode_padding_mode(DecodePaddingMode::Indifferent),
|
||||
);
|
||||
|
||||
/// Don't add padding when encoding, and require no padding when decoding.
|
||||
pub const ENGINE_URL_SAFE: Base64Engine = Base64Engine::new(
|
||||
&alphabet::URL_SAFE,
|
||||
GeneralPurposeConfig::new().with_decode_padding_mode(DecodePaddingMode::Indifferent),
|
||||
);
|
||||
|
||||
pub fn encode<T>(data: T) -> String
|
||||
where
|
||||
T: AsRef<[u8]>,
|
||||
@@ -33,3 +39,17 @@ where
|
||||
data[..len].copy_from_slice(&decoded);
|
||||
Ok(&data[..len])
|
||||
}
|
||||
|
||||
pub fn encode_url_safe<T>(data: T) -> String
|
||||
where
|
||||
T: AsRef<[u8]>,
|
||||
{
|
||||
ENGINE_URL_SAFE.encode(data)
|
||||
}
|
||||
|
||||
pub fn decode_url_safe<T>(data: T) -> Result<Vec<u8>, DecodeError>
|
||||
where
|
||||
T: AsRef<[u8]>,
|
||||
{
|
||||
ENGINE_URL_SAFE.decode(data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user