{"id":42511409,"url":"https://github.com/fluree/crypto-base","last_synced_at":"2026-01-28T14:12:47.241Z","repository":{"id":57255302,"uuid":"216619116","full_name":"fluree/crypto-base","owner":"fluree","description":"Base cryptography functions that are used in Fluree","archived":false,"fork":false,"pushed_at":"2024-02-14T23:46:47.000Z","size":352,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-23T09:14:01.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/fluree.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}},"created_at":"2019-10-21T16:51:51.000Z","updated_at":"2022-02-14T22:49:28.000Z","dependencies_parsed_at":"2024-06-21T15:34:46.203Z","dependency_job_id":"d863f9c2-c92b-4e4d-a8c6-bd642ae89442","html_url":"https://github.com/fluree/crypto-base","commit_stats":null,"previous_names":["fluree/fluree-cryptography-base"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fluree/crypto-base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluree","download_url":"https://codeload.github.com/fluree/crypto-base/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluree%2Fcrypto-base/sbom","scorecard":{"id":404823,"data":{"date":"2025-08-11","repo":{"name":"github.com/fluree/crypto-base","commit":"fc0bf5bff68e48a3ccb83b2e68e8395125847dd8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/9 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":"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":"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":"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":"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":"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":"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":"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":"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"}},{"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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"}}]},"last_synced_at":"2025-08-18T20:55:47.945Z","repository_id":57255302,"created_at":"2025-08-18T20:55:47.945Z","updated_at":"2025-08-18T20:55:47.945Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28846058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T13:02:32.985Z","status":"ssl_error","status_checked_at":"2026-01-28T13:02:04.945Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-28T14:12:46.669Z","updated_at":"2026-01-28T14:12:47.236Z","avatar_url":"https://github.com/fluree.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Cryptography Library for Fluree\n\nA collection of Javascript cryptography functions for Fluree. \n\n```\nnpm install @fluree/crypto-base\n```\n\n## Utility Functions\n\n### Normalize String\n\n- Arguments: `string`\n- Returns: `string`\n\nNormalizes string using the [NKFC](http://unicode.org/reports/tr15/) standard to ensure consistent hashing.\n\n`const normalApple = crypto.normalize_string(\"\\u0041\\u030apple\")`\n\nFor example, we can see that:\n\n`crypto.sha2_256(\"\\u0041\\u030apple\")` results in `6e9288599c1ff90127459f82285327c83fa0541d8b7cd215d0cd9e587150c15f`.\n\nWhile using the normalized version of the string\n\n`crypto.sha2_256_normalize(normalApple)` results in `58acf888b520fe51ecc0e4e5eef46c3bea3ca7df4c11f6719a1c2471bbe478bf`.\n\n### String to Byte Array\n\n- Arguments: `string` or `byte-array`\n- Returns: `byte-array`\n\nThis functions normalizes a string and returns a byte-array. If it is already a byte-array, it returns itself.\n\nFor example: \n\n`crypto.string__GT_byte_array(\"hi there\")` results in `[104, 105, 32, 116, 104, 101, 114, 101]`.\n\n\n### Byte Array to String\n\n- Arguments: `byte-array`\n- Returns: `byte-array`\n\nThis functions takes a byte-array and returns a string. \n\n`crypto.byte_array__GT_string([104, 105, 32, 116, 104, 101, 114, 101])` results in `hi there`.\n\n## Public-key Cryptography\n\n### Generate Key Pair\n\n- Arguments: `none` or `private-key-as-hex-string`\n- Returns: `{ private: \"private-key-as-hex-string\", public: \"public-key-as-hex-string\" } `\n\nThis function will return a map with a public and private key:\n\n`crypto.generate_key_pair();` will return a valid public-private key pair. \n\nFor example, this might return:\n\n`{ private: \"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\", \npublic: \"02991719b37817f6108fc8b0e824d3a9daa3d39bc97ecfd4f8bc7ef3b71d4c6391\"}`. \n\nYou can also call this function with a private key already provided.\n\n`crypto.generate_key_pair(\"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\");`\n\nThis will return:\n\n`{ private: \"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\", \npublic: \"02991719b37817f6108fc8b0e824d3a9daa3d39bc97ecfd4f8bc7ef3b71d4c6391\"}`. \n\n### Public Key from Private\n\n- Arguments: `private-key-as-hex-string`\n- Returns: `public-key-as-hex-string`\n\nGiven a private key, this returns a public key:\n\n`crypto.pub_key_from_private(\"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\");`\n\nThis will return: `02991719b37817f6108fc8b0e824d3a9daa3d39bc97ecfd4f8bc7ef3b71d4c6391`;\n\n### Account Id from Private\n\n- Arguments: `private-key-as-hex-string`\n- Returns: `account-id`\n\nGiven a private key, this will return an account id:\n\n`crypto.account_id_from_private(\"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\");` \n\nThis will return `TfGvAdKH2nRdV4zP4yBz4kJ2R9WzYHDe2EV`.\n\n### Account Id from Public\n\n- Arguments: `public-key-as-hex-string`\n- Returns: `account-id`\n\nGiven a public key, this will return an account id:\n\n`crypto.account_id_from_public(\"02991719b37817f6108fc8b0e824d3a9daa3d39bc97ecfd4f8bc7ef3b71d4c6391\");`\n\nThis will return `TfGvAdKH2nRdV4zP4yBz4kJ2R9WzYHDe2EV`.\n\n### Sign Message\n\n- Arguments: `message, private-key-as-hex-string`\n- Returns: `signature`\n\nGiven a message and a private key, this will return a signature.\n\n```\nconst message = \"hi there\";\nconst privateKey = \"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\";\n\ncrypto.sign_message(message, privateKey);\n```\n\nThis returns: \n\n```\n1b3046022100cbd32e463567fefc2f120425b0224d9d263008911653f50e83953f47cfbef3bc022100fcf81206277aa1b86d2667b4003f44643759b8f4684097efd92d56129cd89ea8\n```\n### Verify Signature\n\n- Arguments: `public-key-as-hex-string, message, signature`\n- Returns: `true` or `false`\n\nGiven a public key, message, and a signature, this function will return true or false.\n\n```\nconst message = \"hi there\";\nconst privateKey = \"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\";\nconst publicKey = \"02991719b37817f6108fc8b0e824d3a9daa3d39bc97ecfd4f8bc7ef3b71d4c6391\";\nconst signature = crypto.sign_message(message, privateKey);\n\ncrypto.verify_signature(publicKey, message, signature);\n\n```\n\nThis returns `true`.\n\n### Public Key from Message\n\n- Arguments: `message, signature`\n- Returns: `true` or `false`\n\n```\nconst message = \"hi there\";\nconst signature = crypto.sign_message(message, \"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\");\n\ncrypto.pub_key_from_message(message, signature);\n```\n\nThis returns `02991719b37817f6108fc8b0e824d3a9daa3d39bc97ecfd4f8bc7ef3b71d4c6391`.\n\n### Account Id from Message\n\n- Arguments: `message, signature`\n- Returns: `true` or `false`\n\n```\nconst message = \"hi there\";\nconst signature = crypto.sign_message(message, \"6a5f415f49986006815ae7887016275aac8ffb239f9a2fa7172300578582b6c2\");\n\ncrypto.account_id_from_message(message, signature);\n```\n\nThis returns `TfGvAdKH2nRdV4zP4yBz4kJ2R9WzYHDe2EV`.\n\n## Hashing\n\n### SHA2 256\n\n- Arguments: `string or byte-array` or `string or byte-array, output-format` or `input in input format, output-format, input-format`\n- Returns: By default `hex-string`.\n\nValid input and output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha2_256(\"hi\");` returns: \n\n`8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4`.\n\n### SHA2 256 Normalize\n\n- Arguments: `string` or `string, output-format` \n- Returns: By default `hex-string`.\n\nValid output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha2_256_normalize(\"hi\")` returns: \n\n`8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4`.\n\n### SHA2 512\n\n- Arguments: `string or byte-array` or `string or byte-array, output-format` or `input in input format, output-format, input-format`\n- Returns: By default `hex-string`.\n\nValid input and output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha2_512(\"hi\");` returns: \n\n`150a14ed5bea6cc731cf86c41566ac427a8db48ef1b9fd626664b3bfbb99071fa4c922f33dde38719b8c8354e2b7ab9d77e0e67fc12843920a712e73d558e197`.\n\n### SHA2 512 Normalize\n\n- Arguments: `string` or `string, output-format`\n- Returns: By default `hex-string`.\n\nValid output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha2_512_normalize(\"hi\");` returns: \n\n`150a14ed5bea6cc731cf86c41566ac427a8db48ef1b9fd626664b3bfbb99071fa4c922f33dde38719b8c8354e2b7ab9d77e0e67fc12843920a712e73d558e197`.\n\n### SHA3 256\n\n- Arguments: `string or byte-array` or `string or byte-array, output-format`\n- Returns: By default `hex-string`.\n\nValid output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha3_256(\"hi\");` returns: \ncrypto\n`b39c14c8da3b23811f6415b7e0b33526d7e07a46f2cf0484179435767e4a8804`.\n\n### SHA3 256 Normalize\n\n- Arguments: `string` or `string, output-format`\n- Returns: By default `hex-string`.\n\nValid output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha3_256_normalize(\"hi\");` returns: \n\n`b39c14c8da3b23811f6415b7e0b33526d7e07a46f2cf0484179435767e4a8804`.\n\n### SHA3 512\n\n- Arguments: `string or byte-array` or `string or byte-array, output-format`\n- Returns: By default `hex-string`.\n\nValid output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha3_512(\"hi\");` returns: \n\n`154013cb8140c753f0ac358da6110fe237481b26c75c3ddc1b59eaf9dd7b46a0a3aeb2cef164b3c82d65b38a4e26ea9930b7b2cb3c01da4ba331c95e62ccb9c3`.\n\n### SHA3 512 Normalize\n\n- Arguments: `string` or `string, output-format`\n- Returns: By default `hex string`.\n\nValid output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.sha3_512_normalize(\"hi\");` returns: \n\n`154013cb8140c753f0ac358da6110fe237481b26c75c3ddc1b59eaf9dd7b46a0a3aeb2cef164b3c82d65b38a4e26ea9930b7b2cb3c01da4ba331c95e62ccb9c3`.\n\n### RIPEMD-160\n\n- Arguments: `string` or `string, output-format` or `string, output-format, input-format`\n- Returns: By default `hex-string`.\n\nValid input or output formats: `hex`, `bytes`, `base64`, `base58`, `string`.\n\nThis function: `crypto.ripemd_160(\"hi\");` returns `242485ab6bfd3502bcb3442ea2e211687b8e4d89`.\n\n## Encryption\n\n### AES Encrypt\n\n- Arguments: `message, iv, key` or `message, iv, key, output-format` \n- Returns: By default `hex-string`.\n\nValid output formats: `hex`, `base64`.\n\n```\nconst initialization_vector = [6, 224, 71, 170, 241, 204, 115, 21, 30, 8, 46, 223, 106, 207, 55, 42];\nconst message = \"hi\";\nconst key = \"there\";\n\ncrypto.aes_encrypt(message, initialization_vector, key);\n```\n\nThis returns: `668cd07d1a17cc7a8a0390cf017ac7ef`.\n\n### AES Decrypt\n\n- Arguments: `x, iv, key` or `x, iv, key, output-format` or `x, iv, key, output-format, input-format`\n- Returns: By default `hex-string`.\n\n```\nconst initialization_vector = [6, 224, 71, 170, 241, 204, 115, 21, 30, 8, 46, 223, 106, 207, 55, 42];\nconst message = \"hi\";\nconst key = \"there\";\nconst encrypted = crypto.aes_encrypt(message, initialization_vector, key);\n\ncrypto.aes_decrypt(encrypted, initialization_vector, key);\n```\n\nThis returns: `hi`.\n\n### Scrypt Encrypt\n\n- Arguments: `message` or `message, salt` or `message, salt, n` or `message, salt, n, r, p` or `message, salt, n, r, p, dk-len`\n- Returns: `hex-string`.\n\nThe arguments by default:\n\n- `salt`: 16 random bytes\n- `n`: 32,768\n- `r`: 8 \n- `p`: 1\n- `dk-len`: 32 \n\n\n```\nconst salt = [172, 28, 242, 108, 175, 130, 214, 6, 249, 61, 244, 178, 34, 8, 13, 178];\n\ncrypto.scrypt_encrypt(\"hi\", salt)\n```\n\nThis results in `57f93bcf926c31a9e2d2129da84bfca51eb9447dfe1749b62598feacaad657d4`.\n\n### Scrypt Check\n\n- Arguments: `message, encrypted, salt` or `message, encrypted, salt, n, r, p`\n- Returns: `true` or `false`\n\nThe arguments by default:\n\n- `n`: 32,768\n- `r`: 8 \n- `p`: 1\n\n```\nconst salt = [172, 28, 242, 108, 175, 130, 214, 6, 249, 61, 244, 178, 34, 8, 13, 178];\n\ncrypto.scrypt_encrypt(\"hi\", salt, 32768, 8, 1)\n\ncrypto.scrypt_check(\"hi\", \"57f93bcf926c31a9e2d2129da84bfca51eb9447dfe1749b62598feacaad657d4\", salt, 32768, 8, 1)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluree%2Fcrypto-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluree%2Fcrypto-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluree%2Fcrypto-base/lists"}