{"id":20975927,"url":"https://github.com/banyc/tokio_chacha20","last_synced_at":"2026-06-19T01:32:07.786Z","repository":{"id":214765877,"uuid":"737297974","full_name":"Banyc/tokio_chacha20","owner":"Banyc","description":"Encrypt/Decrypt async stream data (`AsyncRead/Write`) using (X)ChaCha20","archived":false,"fork":false,"pushed_at":"2025-06-13T11:53:49.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-10T01:18:50.370Z","etag":null,"topics":["chacha20","chacha20-poly1305","poly1305","tokio","xchacha20","xchacha20-poly1305"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Banyc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-30T14:24:36.000Z","updated_at":"2025-06-13T11:53:42.000Z","dependencies_parsed_at":"2023-12-30T16:26:31.355Z","dependency_job_id":"42c77e25-6f29-4128-b297-56f55057a36c","html_url":"https://github.com/Banyc/tokio_chacha20","commit_stats":null,"previous_names":["banyc/tokio_chacha20"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Banyc/tokio_chacha20","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Ftokio_chacha20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Ftokio_chacha20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Ftokio_chacha20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Ftokio_chacha20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Banyc","download_url":"https://codeload.github.com/Banyc/tokio_chacha20/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Banyc%2Ftokio_chacha20/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34514282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chacha20","chacha20-poly1305","poly1305","tokio","xchacha20","xchacha20-poly1305"],"created_at":"2024-11-19T04:48:06.802Z","updated_at":"2026-06-19T01:32:07.758Z","avatar_url":"https://github.com/Banyc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `tokio_chacha20`\n\nChaCha20 and Poly1305 primitives (primitives are not AEAD).\n\n## How to use\n\nAsync:\n\n```rust\n#[tokio::test]\nasync fn test_simplex_async() {\n    let config = create_random_config();\n\n    let (client, server) = tokio::io::duplex(1024);\n    let (mut server, mut client) = same_key_nonce_ciphertext(config.key(), server, client);\n\n    let data = b\"Hello, world!\";\n    let mut buf = [0u8; 1024];\n\n    for _ in 0..1024 {\n        client.write_all(data).await.unwrap();\n        server.read_exact(\u0026mut buf[..data.len()]).await.unwrap();\n        assert_eq!(\u0026buf[..data.len()], data);\n    }\n}\n```\n\nPolling:\n\n```rust\n#[test]\nfn test_simplex_polling() {\n    let config = create_random_config();\n\n    let msg = b\"Hello world!\";\n    let mut nonce_ciphertext = vec![];\n\n    let mut w = nonce_ciphertext_writer(config.key(), \u0026mut nonce_ciphertext);\n    unwrap_ready(Pin::new(\u0026mut w).poll_write(\u0026mut noop_context(), msg)).unwrap();\n\n    let mut r = nonce_ciphertext_reader(config.key(), \u0026nonce_ciphertext[..]);\n    let mut read_buf = vec![0; 1024];\n    let mut read_buf = ReadBuf::new(\u0026mut read_buf);\n    unwrap_ready(Pin::new(\u0026mut r).poll_read(\u0026mut noop_context(), \u0026mut read_buf)).unwrap();\n    assert_eq!(msg, read_buf.filled());\n}\nfn noop_context() -\u003e Context\u003c'static\u003e {\n    Context::from_waker(Waker::noop())\n}\nfn unwrap_ready\u003cT\u003e(poll: Poll\u003cT\u003e) -\u003e T {\n    match poll {\n        Poll::Ready(x) =\u003e x,\n        Poll::Pending =\u003e panic!(),\n    }\n}\n```\n\nCipher:\n\n```rust\nfn same_key_nonce_ciphertext\u003cR, W\u003e(\n    key: \u0026[u8; KEY_BYTES],\n    r: R,\n    w: W,\n) -\u003e (NonceCiphertextReader\u003cR\u003e, NonceCiphertextTagWriter\u003cW\u003e) {\n    let r = nonce_ciphertext_reader(key, r);\n    let w = nonce_ciphertext_writer(key, w);\n    (r, w)\n}\nfn nonce_ciphertext_reader\u003cR\u003e(key: \u0026[u8; KEY_BYTES], r: R) -\u003e NonceCiphertextReader\u003cR\u003e {\n    let reader_config = NonceCiphertextReaderConfig { hash: false };\n    let nonce_buf = NonceBuf::Nonce(Box::new([0; NONCE_BYTES]));\n    NonceCiphertextReader::new(\u0026reader_config, Box::new(*key), nonce_buf, r)\n}\nfn nonce_ciphertext_writer\u003cW\u003e(key: \u0026[u8; KEY_BYTES], w: W) -\u003e NonceCiphertextTagWriter\u003cW\u003e {\n    let writer_config = NonceCiphertextWriterConfig {\n        write_nonce: true,\n        hash: false,\n        key,\n    };\n    let nonce = NonceBuf::Nonce(Box::new(rand::random()));\n    NonceCiphertextTagWriter::new(\u0026writer_config, nonce, w)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbanyc%2Ftokio_chacha20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbanyc%2Ftokio_chacha20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbanyc%2Ftokio_chacha20/lists"}