Crates.io | tc_tea |
lib.rs | tc_tea |
version | 0.2.0 |
source | src |
created_at | 2021-12-28 22:38:52.272997 |
updated_at | 2024-09-11 23:19:03.135784 |
description | Rusty implementation of Tencent's varient of TEA (tc_tea). |
homepage | |
repository | https://github.com/jixunmoe/tc_tea_rust/ |
max_upload_size | |
id | 504475 |
size | 18,400 |
Rusty implementation of Tencent modified TEA (tc_tea).
Test data generated using its C++ implementation: tc_tea.cpp (BSD-3-Clause).
Code implemented according to the spec described in iweizime/StepChanger:腾讯 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.
Add the following to [dependencies]
section in your Cargo.toml
file:
tc_tea = "0.2"
use tc_tea;
fn hello_tc_tea() {
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());
}
Dual licensed under MIT OR Apache-2.0 license.
SPDX-License-Identifier: MIT OR Apache-2.0