From e6c75baa5e57922f7edb7fadd2d1fa02ab210647 Mon Sep 17 00:00:00 2001 From: Jixun Wu <8041017-jixunmoe@users.noreply.gitlab.com> Date: Thu, 12 Sep 2024 00:18:39 +0100 Subject: [PATCH] docs: update docs --- README.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index aee1c20..a359be1 100644 --- a/README.md +++ b/README.md @@ -9,31 +9,27 @@ Code implemented according to the spec described in ## Features -* `secure_random` (default: `on`): Enable secure RNG when generating padding bytes for tc_tea. +* `random` (default: `on`): Enable RNG when generating padding bytes for tc_tea. +* `random_secure` (default: `on`): Use a _secure_ RNG when generating padding bytes for tc_tea. + +If you don't expect to encrypt anything, you can specify `default-features = false` to drop RNG support. +In this case, it will use a [pre-generated deterministic salt](https://xkcd.com/221/). ## Install Add the following to `[dependencies]` section in your `Cargo.toml` file: ```toml -tc_tea = "0.1.4" +tc_tea = "0.2" ``` -## Troubleshooting - -* Key need to have `16` bytes or more. - * `None` will be returned if less than `16` bytes provided. - * If more bytes were provided, only the first 16 bytes will be used. -* Encrypted data should have a size that is multiple of 8. - * `None` will be returned if `encrypted_data.len() % 8 > 0`. - ## Usage ```rust use tc_tea; fn hello_tc_tea() { - let key = "12345678ABCDEFGH"; + let key = b"12345678ABCDEFGH"; let encrypted = tc_tea::encrypt(&"hello", &key).unwrap(); let decrypted = tc_tea::decrypt(&encrypted, &key).unwrap(); assert_eq!("hello", std::str::from_utf8(&decrypted).unwrap()); @@ -49,4 +45,5 @@ SPDX-License-Identifier: MIT OR Apache-2.0 ``` [tc_tea_cpp]: https://github.com/TarsCloud/TarsCpp/blob/a6d5ed8/util/src/tc_tea.cpp + [tc_tea_spec]: https://github.com/iweizime/StepChanger/wiki/%E8%85%BE%E8%AE%AFTEA%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95