From 76ae128d68b710d73a447ad5f04468b090ebc199 Mon Sep 17 00:00:00 2001 From: Jixun Wu Date: Wed, 29 Dec 2021 00:20:00 +0000 Subject: [PATCH] fix: off by one bit --- Cargo.toml | 2 +- README.md | 2 +- src/tc_tea.rs | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d2ddb0b..0de761f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "tc_tea" -version = "0.1.1" +version = "0.1.2" authors = ["Jixun Wu "] edition = "2021" diff --git a/README.md b/README.md index 7111cb0..efff433 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Code implemented according to the spec described in Add the following to `[dependencies]` section in your `Cargo.toml` file: ```toml -tc_tea = "0.1.1" +tc_tea = "0.1.2" ``` ## Troubleshooting diff --git a/src/tc_tea.rs b/src/tc_tea.rs index 39c0a75..7165267 100644 --- a/src/tc_tea.rs +++ b/src/tc_tea.rs @@ -60,7 +60,7 @@ pub fn encrypt, K: AsRef<[u8]>>(plaintext: T, key: K) -> Option input.len()); + eprintln!(":2 encrypted.len(): {}", encrypted.len()); + + // Since encryption utilises random numbers, we are just going to + let decrypted = decrypt(encrypted, ENCRYPTION_KEY).unwrap(); + assert_eq!(&*decrypted, input); + eprintln!("run {} ok", i) + } + } + #[test] fn test_calc_encrypted_size() { assert_eq!(calc_encrypted_size(0), 16);