Module ubiq::decryption
source · Expand description
Interfaces for decrypting data
Examples
Simple
use ubiq::credentials::Credentials;
use ubiq::encryption::encrypt;
use ubiq::decryption::decrypt;
let creds = Credentials::new(None, None).unwrap();
let ct = encrypt(&creds, b"abc").unwrap();
let pt = decrypt(&creds, &ct).unwrap();
assert!(pt != ct);
assert!(pt == b"abc");
Piecewise
use ubiq::credentials::Credentials;
use ubiq::encryption::encrypt;
use ubiq::decryption::Decryption;
let creds = Credentials::new(None, None).unwrap();
let ct = encrypt(&creds, b"abc").unwrap();
let mut dec = Decryption::new(&creds).unwrap();
/*
* ct can be passed to the decryption process in
* as many or as few pieces as desired
*/
let mut pt = dec.begin().unwrap();
pt.extend(dec.update(&ct[0..3]).unwrap());
pt.extend(dec.update(&ct[3..9]).unwrap());
pt.extend(dec.update(&ct[9..24]).unwrap());
pt.extend(dec.update(&ct[24..]).unwrap());
pt.extend(dec.end().unwrap());
assert!(pt != ct);
assert!(pt == b"abc");
/*
* the dec object can now be reused by following the
* begin(), update()..., end() process shown above for
* as many times as desired.
*/
Structs
- Structure encompassing parameters used for decrypting data
Functions
- Decrypt a single ciphertext