{"id":31921862,"url":"https://github.com/rmw-lib/xxblake3","last_synced_at":"2025-10-13T22:55:14.295Z","repository":{"id":57672685,"uuid":"379119529","full_name":"rmw-lib/xxblake3","owner":"rmw-lib","description":null,"archived":false,"fork":false,"pushed_at":"2022-09-23T08:37:03.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-19T06:19:52.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rmw-lib.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}},"created_at":"2021-06-22T02:32:36.000Z","updated_at":"2022-11-28T18:46:23.000Z","dependencies_parsed_at":"2022-08-31T08:22:04.472Z","dependency_job_id":null,"html_url":"https://github.com/rmw-lib/xxblake3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rmw-lib/xxblake3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fxxblake3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fxxblake3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fxxblake3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fxxblake3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmw-lib","download_url":"https://codeload.github.com/rmw-lib/xxblake3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fxxblake3/sbom","scorecard":{"id":779229,"data":{"date":"2025-08-11","repo":{"name":"github.com/rmw-lib/xxblake3","commit":"e956e60939352291b1d6c3208364eeb2d578719e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T04:29:24.299Z","repository_id":57672685,"created_at":"2025-08-23T04:29:24.299Z","updated_at":"2025-08-23T04:29:24.299Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017087,"owners_count":26085984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"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":[],"created_at":"2025-10-13T22:55:08.278Z","updated_at":"2025-10-13T22:55:14.289Z","avatar_url":"https://github.com/rmw-lib.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- 本文件由 ./readme.make.md 自动生成，请不要直接修改此文件 --\u003e\n\n# xxblake3\n\nencryption and decryption based on xxh3 and blake3\n\nsee [tests/main.rs](https://docs.rs/crate/xxblake3/0.0.1/source/tests/main.rs) for usage\n\n```rust\nuse xxblake3::{decrypt, encrypt};\n\n#[test]\nfn main() {\n  let secret = [\n    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,\n    27, 28, 29, 30, 31, 32,\n  ];\n\n  let iv = 1u32.to_le_bytes();\n  let data = \"test msg\".as_bytes();\n\n  let mut encrypted = encrypt(\u0026secret, \u0026iv, data);\n\n  println!(\"data len {}\", data.len());\n  println!(\"encrypted len {}\", encrypted.len());\n\n  assert_eq!(*data, *decrypt(\u0026secret, \u0026iv, \u0026encrypted).unwrap());\n\n  encrypted[9] = !encrypted[9];\n\n  assert_eq!(None, decrypt(\u0026secret, \u0026iv, \u0026encrypted));\n}\n```\n\nimpl code\n\n```rust\n#![feature(new_uninit)]\n\nuse blake3::Hasher;\nuse core::hash::Hasher as _;\nuse std::convert::TryInto;\nuse twox_hash::xxh3::{hash64, Hash64};\n\nconst LEN_U64: usize = std::mem::size_of::\u003cu64\u003e();\nconst H64_SEED: u64 = 1;\n\n#[inline]\npub fn hash_data_secret(secret: \u0026[u8], data: \u0026[u8]) -\u003e u64 {\n  let mut h64 = Hash64::with_seed(H64_SEED);\n  h64.write(data);\n  h64.write(secret);\n  h64.finish()\n}\n\nmacro_rules! xor {\n  ($out:expr, $x:expr) =\u003e {\n    $out.iter_mut().zip($x.iter()).for_each(|(a, b)| *a ^= *b);\n  };\n}\n\npub fn encrypt(secret: \u0026[u8], iv: \u0026[u8], data: \u0026[u8]) -\u003e Box\u003c[u8]\u003e {\n  let hash = hash64(data);\n\n  let out_len = LEN_U64 + data.len();\n  let mut out = unsafe { Box::\u003c[u8]\u003e::new_uninit_slice(out_len).assume_init() };\n  let out_data = \u0026mut out[LEN_U64..];\n\n  Hasher::new()\n    .update(\u0026hash.to_le_bytes())\n    .update(iv)\n    .update(secret)\n    .finalize_xof()\n    .fill(out_data);\n\n  xor!(out_data, data);\n\n  let hash = hash_data_secret(out_data, secret) ^ hash;\n\n  out[..LEN_U64].clone_from_slice(\u0026hash.to_le_bytes());\n\n  out\n}\n\npub fn decrypt(secret: \u0026[u8], iv: \u0026[u8], data: \u0026[u8]) -\u003e Option\u003cBox\u003c[u8]\u003e\u003e {\n  let ed = \u0026data[LEN_U64..];\n  let hash = u64::from_le_bytes(data[..LEN_U64].try_into().unwrap()) ^ hash_data_secret(ed, secret);\n  let out_len = data.len() - LEN_U64;\n  let mut out = unsafe { Box::\u003c[u8]\u003e::new_uninit_slice(out_len).assume_init() };\n\n  Hasher::new()\n    .update(\u0026hash.to_le_bytes())\n    .update(iv)\n    .update(secret)\n    .finalize_xof()\n    .fill(\u0026mut out);\n\n  xor!(out, ed);\n\n  if hash64(\u0026out) != hash {\n    None\n  } else {\n    Some(out)\n  }\n}\n```\n\n## step\n\n加密流程 :\n\n  1. 校验码 = xxh3::Hash64(原始内容) // seed = 0\n  1. 流密码 = blake3(校验码+秘钥), 哈希输出长度=内容长度\n  1. 加密内容 = 原始内容 异或 流密码\n  1. 加密校验码 = xxh3::Hash64(加密内容+秘钥) 异或 校验码 // seed = 1\n  1. 输出 = 加密校验码 + 加密内容\n\n解密流程 :\n\n  1. 校验码 = xxh3::Hash64(加密内容+秘钥) 异或 加密校验码 // seed = 1\n  1. 流密码 = blake3(校验码+秘钥), 哈希输出长度=内容长度\n  1. 解密内容 = 加密内容 异或 流密码\n  1. 完整性效验 : 计算 xxh3::Hash64(解密内容) == 校验码 // seed = 0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmw-lib%2Fxxblake3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmw-lib%2Fxxblake3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmw-lib%2Fxxblake3/lists"}