diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index e3ef2667..343efd86 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -32,3 +32,32 @@ jobs: - name: Run cargo fmt run: cargo fmt --all -- --check + + doc: + name: rustdoc + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: dtolnay/rust-toolchain@master + with: + # We need Nightly for doc_cfg + toolchain: nightly-2026-03-29 + - uses: Swatinem/rust-cache@v2 + - name: Generate Docs + env: + RUSTDOCFLAGS: -Dwarnings --cfg docsrs + run: cargo doc --no-deps + + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: crate-ci/typos@v1 + + lockfile: + name: Check Cargo.lock + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: dtolnay/rust-toolchain@stable + - run: cargo check --workspace --locked diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 00000000..dbd69349 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,10 @@ +[files] +extend-exclude = [ + ".git/" +] + +[default] +extend-ignore-re = [ + # Patterns which appear to be 32 or more hex characters + '\b[0-9A-H+/]{32,}\b', +] diff --git a/chacha20/README.md b/chacha20/README.md index 11359ffb..865c25e2 100644 --- a/chacha20/README.md +++ b/chacha20/README.md @@ -54,8 +54,8 @@ use hex_literal::hex; let key = [0x42; 32]; let nonce = [0x24; 12]; -let plaintext = hex!("00010203 04050607 08090A0B 0C0D0E0F"); -let ciphertext = hex!("e405626e 4f1236b3 670ee428 332ea20e"); +let plaintext = hex!("000102030405060708090A0B0C0D0E0F"); +let ciphertext = hex!("e405626e4f1236b3670ee428332ea20e"); // Key and IV must be references to the `Array` type. // Here we use the `Into` trait to convert arrays into it. diff --git a/hc-256/README.md b/hc-256/README.md index 046f13c5..75af424b 100644 --- a/hc-256/README.md +++ b/hc-256/README.md @@ -31,8 +31,8 @@ use hex_literal::hex; let key = [0x42; 32]; let nonce = [0x24; 32]; -let plaintext = hex!("00010203 04050607 08090A0B 0C0D0E0F"); -let ciphertext = hex!("ca982177 325cd40e bc208045 066c420f"); +let plaintext = hex!("000102030405060708090A0B0C0D0E0F"); +let ciphertext = hex!("ca982177325cd40ebc208045066c420f"); // Key and IV must be references to the `Array` type. // Here we use the `Into` trait to convert arrays into it. diff --git a/rabbit/README.md b/rabbit/README.md index 205776cf..cc745fc4 100644 --- a/rabbit/README.md +++ b/rabbit/README.md @@ -32,8 +32,8 @@ use hex_literal::hex; let key = [0x42; 16]; let nonce = [0x24; 8]; -let plaintext = hex!("00010203 04050607 08090A0B 0C0D0E0F"); -let ciphertext = hex!("10298496 ceda18ee 0e257cbb 1ab43bcc"); +let plaintext = hex!("000102030405060708090A0B0C0D0E0F"); +let ciphertext = hex!("10298496ceda18ee0e257cbb1ab43bcc"); // Key and IV must be references to the `Array` type. // Here we use the `Into` trait to convert arrays into it. diff --git a/rabbit/src/lib.rs b/rabbit/src/lib.rs index 5614ee6c..1d3ee20e 100644 --- a/rabbit/src/lib.rs +++ b/rabbit/src/lib.rs @@ -41,9 +41,9 @@ pub type Iv = cipher::Iv; type BlockSize = U16; -/// The Rabbit stream cipher initializied only with key. +/// The Rabbit stream cipher initialized only with key. pub type RabbitKeyOnly = StreamCipherCoreWrapper; -/// The Rabbit stream cipher initializied with key and IV. +/// The Rabbit stream cipher initialized with key and IV. pub type Rabbit = StreamCipherCoreWrapper; /// RFC 4503. 2.2. Inner State (page 2). diff --git a/rc4/README.md b/rc4/README.md index 8b138d20..788c8014 100644 --- a/rc4/README.md +++ b/rc4/README.md @@ -32,23 +32,20 @@ use rc4::{consts::*, KeyInit, StreamCipher}; use rc4::{Key, Rc4}; let mut rc4 = Rc4::::new(b"Key".into()); -let mut data = b"Plaintext".to_vec(); +let mut data = *b"Plaintext"; rc4.apply_keystream(&mut data); -assert_eq!(data, [0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3]); +assert_eq!(data, hex!("BBF316E8D940AF0AD3")); let mut rc4 = Rc4::::new(b"Wiki".into()); -let mut data = b"pedia".to_vec(); +let mut data = *b"pedia"; rc4.apply_keystream(&mut data); -assert_eq!(data, [0x10, 0x21, 0xBF, 0x04, 0x20]); +assert_eq!(data, hex!("1021BF0420")); let key = Key::::from_slice(b"Secret"); let mut rc4 = Rc4::<_>::new(key); -let mut data = b"Attack at dawn".to_vec(); +let mut data = *b"Attack at dawn"; rc4.apply_keystream(&mut data); -assert_eq!( - data, - [0x45, 0xA0, 0x1F, 0x64, 0x5F, 0xC3, 0x5B, 0x38, 0x35, 0x52, 0x54, 0x4B, 0x9B, 0xF5] -); +assert_eq!(data, hex!("45A01F645FC35B383552544B9BF5")); ``` ## License diff --git a/salsa20/README.md b/salsa20/README.md index ebbf5b17..13ae8839 100644 --- a/salsa20/README.md +++ b/salsa20/README.md @@ -32,8 +32,8 @@ use hex_literal::hex; let key = [0x42; 32]; let nonce = [0x24; 8]; -let plaintext = hex!("00010203 04050607 08090A0B 0C0D0E0F"); -let ciphertext = hex!("85843cc5 d58cce7b 5dd3dd04 fa005ded"); +let plaintext = hex!("000102030405060708090A0B0C0D0E0F"); +let ciphertext = hex!("85843cc5d58cce7b5dd3dd04fa005ded"); // Key and IV must be references to the `Array` type. // Here we use the `Into` trait to convert arrays into it.