Skip to main content

Encrypted

Derive Macro Encrypted 

Source
#[derive(Encrypted)]
{
    // Attributes available to this derive:
    #[encrypt]
}
Expand description

Derive macro that generates an encrypted version of a struct and Encryptable trait impl.

Fields annotated with #[encrypt] will be encrypted using AES-256-GCM when encrypt() is called. Non-annotated fields are copied as-is.

#[encrypt] only works on String fields.

§Example

#[derive(Encrypted, Serialize, Deserialize, Clone, Debug, PartialEq)]
struct UserRecord {
    user_id: String,
    #[encrypt]
    ssn: String,
    #[encrypt]
    bank_account: String,
    email: String,
}

This generates EncryptedUserRecord and an Encryptable impl on UserRecord.