pub struct FieldEncryption { /* private fields */ }
Expand description

FieldEncryption struct. Provides methods to encrypt values matching the input regex to a value matching the output regex (and to decrypt).

Both regular expressions must be finite, i.e. they must contain a bounded number of possible values - so no unbounded expressions such as .* or [0-9]+ are permitted.

Furthermore the number of possible values of the output regex must be equal to, or greater than, the number of possible values of the input regex, i.e. the ‘domain’ of the output regex must be greater than or equal to the ‘domain’ pf the input regex.

Implementations

Create a new FieldEncryption instance.

Arguments
  • input_regex - the regular expression that describes all inputs
  • output_regex - the regular expression that describes all outputs
  • key - the encryption key, must be at least 32 bytes
Errors
  • InfiniteRegex - if either regex is infinite
  • OutputDomainTooSmall - if the domain of the output regex is < domain of the input regex
  • InvalidKeyLength - of the encryption key is too small

Encrypts the supplied input.

Errors
  • InvalidInput - if the specified value does not match the input regex

Decrypts the supplied input.

Errors
  • InvalidInput - if the specified value does not match the output regex

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.