3个版本 (破坏性)

使用旧的Rust 2015

0.3.0 2019年1月27日
0.2.0 2018年9月13日
0.1.0 2016年3月6日

#1042密码学

Download history 32229/week @ 2024-03-14 36061/week @ 2024-03-21 35911/week @ 2024-03-28 42422/week @ 2024-04-04 38217/week @ 2024-04-11 38820/week @ 2024-04-18 33445/week @ 2024-04-25 32932/week @ 2024-05-02 32900/week @ 2024-05-09 32044/week @ 2024-05-16 44301/week @ 2024-05-23 32722/week @ 2024-05-30 23985/week @ 2024-06-06 33020/week @ 2024-06-13 29329/week @ 2024-06-20 21068/week @ 2024-06-27

112,590 每月下载量
用于 97 个crate(9 个直接)

MIT/Apache

36KB
635

documenation crates.io link

添加依赖

如果您使用稳定版的Rust构建

[dependencies]
chacha = "0.1.0"

如果您需要最大性能,请使用nightly版的Rust构建

[dependencies.chacha]
version = "0.1.0"
features = ["nightly"]

示例

extern crate chacha;

use chacha::{ChaCha, KeyStream};

fn main() {
    let secret_key = [
        0x29, 0xfa, 0x35, 0x60, 0x88, 0x45, 0xc6, 0xf9, 
        0xd8, 0xfe, 0x65, 0xe3, 0x22, 0x0e, 0x5b, 0x05, 
        0x03, 0x4a, 0xa0, 0x9f, 0x9e, 0x27, 0xad, 0x0f, 
        0x6c, 0x90, 0xa5, 0x73, 0xa8, 0x10, 0xe4, 0x94, 
    ];
    let nonce = [0u8; 8];
    let mut stream = ChaCha::new_chacha20(&secret_key, &nonce);

    let mut buffer = *b"abcdef";
    println!("Plaintext = {:?}", buffer);
    stream.xor_read(&mut buffer[..]).expect("hit end of stream far too soon");
    println!("Ciphertext = {:?}", buffer);
}

依赖

~125KB