#摘要 #隐私 #加密 #iop #哈希 #JSON #隐私保护

json-digest

允许对 JSON 子文档进行选择性掩码以保护隐私,同时保留整个文档的摘要

3 个版本

0.0.16 2022 年 6 月 30 日
0.0.15 2021 年 11 月 9 日
0.0.5 2020 年 9 月 21 日

#13#隐私保护

Download history 72/week @ 2024-03-13 93/week @ 2024-03-20 127/week @ 2024-03-27 120/week @ 2024-04-03 44/week @ 2024-04-10 54/week @ 2024-04-17 54/week @ 2024-04-24 51/week @ 2024-05-01 67/week @ 2024-05-08 48/week @ 2024-05-15 51/week @ 2024-05-22 44/week @ 2024-05-29 48/week @ 2024-06-05 48/week @ 2024-06-12 55/week @ 2024-06-19 57/week @ 2024-06-26

212 每月下载量
用于 13 个 crate(9 个直接使用)

LGPL-3.0-or-later

27KB
415

此库提供了一些计算 JSON 文档加密安全摘要的算法。由于 JSON 是一种歧义性序列化格式,我们还需要定义所有允许文档的规范确定性子集。该子集中对象键的顺序和 Unicode 规范化都是明确的,使其适用于哈希。

let data = serde_json::json!({
  "address": {
    "value": "6 Unter den Linden, Berlin, Germany",
    "nonce": "uN_FTaYe8JM-EZ8SU94kAOf0k0YvnhLcZgdpQ3BU9Ymbu"
  },
  "dateOfBirth": {
    "value": "16/02/2002",
    "nonce": "ufxkENKgXuf4yG50p6xpSyaQ8Gz7KsuqXid2yw533TUMK"
  },
  "placeOfBirth": {
    "city": "Berlin",
    "country": "Germany",
    "nonce": "ukhFsI4a6vIZEDUOBRxJmLroPEQ8FQCjJwbI-Z7bEocGo"
  },
});

let digest = json_digest::digest_data(&data).unwrap();
assert_eq!(digest, "cjuQR3pDJeaiRv9oCZ-fBE7T8QWpUGfjP40sAXq0bLwr-8");

let partial_digest = json_digest::selective_digest_data(&data, ".dateOfBirth").unwrap();
let expected_partial_digest = serde_json::json!({
  "address": "cjuvIf1PmPH_31JN5XqJ1xkcNDJyiw9zQ-7ansSB78gnt4",
  "dateOfBirth": {
    "nonce": "ufxkENKgXuf4yG50p6xpSyaQ8Gz7KsuqXid2yw533TUMK",
    "value":"16/02/2002"
  },
  "placeOfBirth": "cjub0Nxb0Kz0pI4bWCdSbaCutk1s5qieFT-ZmqUU1xcuAc"
});
assert_eq!(partial_digest, serde_json::to_string(&expected_partial_digest).unwrap());

let digest_from_partial = json_digest::digest_json_str(&partial_digest).unwrap();
assert_eq!(digest, digest_from_partial);

依赖项

~3.5–4.5MB
~117K SLoC