encryptor 0.1.0

Password-based encryption for Web3 wallet seed phrases
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use encryptor::{decrypt, encrypt};

/// Ensure we can encrypt and decrypt a message, and that
/// decryption fails with the wrong password.
#[test]
fn roundtrip() {
    let msg = "alice bob chloe";
    let pass = "Abc@1234";

    let blob = encrypt(msg, pass).expect("encryption must succeed");
    assert_eq!(msg, decrypt(&blob, pass).expect("decryption must succeed"));

    // A wrong password should give an error, not plaintext.
    assert!(decrypt(&blob, "wrong pass").is_err());
}