Skip to main content

AsymmetricCipher

Trait AsymmetricCipher 

Source
pub trait AsymmetricCipher:
    Identified
    + Send
    + Sync {
    // Required methods
    fn encrypt(&self, plaintext: &[u8], public_key_hex: &str) -> Result<String>;
    fn decrypt(
        &self,
        ciphertext_hex: &str,
        private_key_hex: &str,
    ) -> Result<Vec<u8>>;
}
Expand description

非对称加密:每次调用传入密钥材料(十六进制,格式由实现决定,如 SM2)。

Required Methods§

Source

fn encrypt(&self, plaintext: &[u8], public_key_hex: &str) -> Result<String>

返回十六进制密文。

Source

fn decrypt( &self, ciphertext_hex: &str, private_key_hex: &str, ) -> Result<Vec<u8>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§