{"id":30481028,"url":"https://github.com/query-farm/crypto","last_synced_at":"2025-08-24T13:35:52.298Z","repository":{"id":246132205,"uuid":"820194453","full_name":"Query-farm/crypto","owner":"Query-farm","description":"DuckDB Extension for cryptographic hash functions and HMAC","archived":false,"fork":false,"pushed_at":"2025-06-09T17:32:24.000Z","size":69,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-19T07:11:37.788Z","etag":null,"topics":["crypto","duckdb","duckdb-extension","hash-functions","hmac"],"latest_commit_sha":null,"homepage":"https://query.farm/duckdb_extension_crypto.html","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Query-farm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-06-26T02:00:44.000Z","updated_at":"2025-06-09T17:32:23.000Z","dependencies_parsed_at":"2025-06-01T18:44:19.420Z","dependency_job_id":null,"html_url":"https://github.com/Query-farm/crypto","commit_stats":null,"previous_names":["rustyconover/duckdb-crypto-extension","query-farm/crypto"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Query-farm/crypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Query-farm%2Fcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Query-farm%2Fcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Query-farm%2Fcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Query-farm%2Fcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Query-farm","download_url":"https://codeload.github.com/Query-farm/crypto/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Query-farm%2Fcrypto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271875796,"owners_count":24837305,"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-08-24T02:00:11.135Z","response_time":111,"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":["crypto","duckdb","duckdb-extension","hash-functions","hmac"],"created_at":"2025-08-24T13:35:47.266Z","updated_at":"2025-08-24T13:35:52.290Z","avatar_url":"https://github.com/Query-farm.png","language":"Rust","readme":"# Crypto Hash/HMAC Extension for DuckDB\n\nThis extension, `crypto`, adds cryptographic hash functions and the ability to calculate HMAC codes to DuckDB.\n\nDuckDB already includes a few functions to calculate hash values, but this extension adds additional hashing algorithms.\n\n## Installation\n\n**`crypto` is a [DuckDB Community Extension](https://github.com/duckdb/community-extensions).**\n\nYou can now use this by using this SQL:\n\n```sql\ninstall crypto from community;\nload crypto;\n```\n\n## Hash Digests\n\n```sql\n-- Calculate some hash digest values.\n select crypto_hash('sha2-256', 'test');\n┌──────────────────────────────────────────────────────────────────┐\n│                 crypto_hash('sha2-256', 'test')                  │\n│                             varchar                              │\n├──────────────────────────────────────────────────────────────────┤\n│ 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 │\n└──────────────────────────────────────────────────────────────────┘\n\nselect crypto_hash('md5', 'test');\n┌──────────────────────────────────┐\n│    crypto_hash('md5', 'test')    │\n│             varchar              │\n├──────────────────────────────────┤\n│ 098f6bcd4621d373cade4e832627b4f6 │\n└──────────────────────────────────┘\n```\n\n### Function Description\n\n`crypto_hash(hash_function_name:VARCHAR, value_to_hash:VARCHAR)`\n\nCalculate the value produced by applying a specified hash function.\n\nThe supported hash functions are:\n\n- `blake2b-512`\n- `keccak224`\n- `keccak256`\n- `keccak384`\n- `keccak512`\n- `md4`\n- `md5`\n- `sha1`\n- `sha2-224`\n- `sha2-256`\n- `sha2-384`\n- `sha2-512`\n- `sha3-224`\n- `sha3-256`\n- `sha3-384`\n- `sha3-512`\n\nThere result is a lowercase hexadecimal representation of the hash result.\n\nDuckDb already has a function called `hash()` and a function for `sha256()`.\n\n## HMAC calculation\n\n```sql\nselect crypto_hmac('sha2-256', 'secret key', 'secret message');\n┌──────────────────────────────────────────────────────────────────┐\n│     crypto_hmac('sha2-256', 'secret key', 'secret message')      │\n│                             varchar                              │\n├──────────────────────────────────────────────────────────────────┤\n│ 2df792e08cefdc0ea9900c67c93cbe66b98231b829a5dccd3857a03baac35963 │\n└──────────────────────────────────────────────────────────────────┘\n```\n\n`crypto_hmac(hash_function_name:VARCHAR, secret_key:VARCHAR, message:VARCHAR)`\n\nThe same list of hash functions that `crypto_hash()` supports are available for use.\n\n### Build Architecture\n\nThis repository is based on https://github.com/duckdb/extension-template, check it out if you want to build and ship your own DuckDB extension.\n\nThe unique nature of this extension is that it combines a Rust crate (`duckdb_crypto_rust`) with the DuckDB extension template, using a tool called [Corrosion](https://github.com/corrosion-rs/corrosion).  Corrosion handles building the embedded Rust crate as a library, then facilitates the Rust crate being linked link to the DuckDB extension.\n\nFor the DuckDB extension to call the Rust code a tool called `cbindgen` is used to write the C++ headers for the exposed Rust interface.\n\nThe headers can be updated by running `make rust_binding_headers`.\n\n### Build steps\nNow to build the extension, run:\n```sh\nmake\n```\nThe main binaries that will be built are:\n```sh\n./build/release/duckdb\n./build/release/test/unittest\n./build/release/extension/crypto/crypto.duckdb_extension\n```\n- `duckdb` is the binary for the duckdb shell with the extension code automatically loaded.\n- `unittest` is the test runner of duckdb. Again, the extension is already linked into the binary.\n- `crypto.duckdb_extension` is the loadable binary as it would be distributed.\n\n## Running the extension\nTo run the extension code, simply start the shell with `./build/release/duckdb`.\n\nNow we can use the features from the extension directly in DuckDB. The template contains a single scalar function `crypto()` that takes a string arguments and returns a string:\n```\nD select crypto_hash('md5', 'test');\n┌──────────────────────────────────┐\n│    crypto_hash('md5', 'test')    │\n│             varchar              │\n├──────────────────────────────────┤\n│ 098f6bcd4621d373cade4e832627b4f6 │\n└──────────────────────────────────┘\n```\n\n## Running the tests\nDifferent tests can be created for DuckDB extensions. The primary way of testing DuckDB extensions should be the SQL tests in `./test/sql`. These SQL tests can be run using:\n```sh\nmake test\n```\n\n### Installing the deployed binaries\nTo install your extension binaries from S3, you will need to do two things. Firstly, DuckDB should be launched with the\n`allow_unsigned_extensions` option set to true. How to set this will depend on the client you're using. Some examples:\n\nCLI:\n```shell\nduckdb -unsigned\n```\n\nPython:\n```python\ncon = duckdb.connect(':memory:', config={'allow_unsigned_extensions' : 'true'})\n```\n\nNodeJS:\n```js\ndb = new duckdb.Database(':memory:', {\"allow_unsigned_extensions\": \"true\"});\n```\n\nSecondly, you will need to set the repository endpoint in DuckDB to the HTTP url of your bucket + version of the extension\nyou want to install. To do this run the following SQL query in DuckDB:\n```sql\nSET custom_extension_repository='bucket.s3.us-east-1.amazonaws.com/crypto/latest';\n```\nNote that the `/latest` path will allow you to install the latest extension version available for your current version of\nDuckDB. To specify a specific version, you can pass the version instead.\n\nAfter running these steps, you can install and load your extension using the regular INSTALL/LOAD commands in DuckDB:\n```sql\nINSTALL crypto\nLOAD crypto\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquery-farm%2Fcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquery-farm%2Fcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquery-farm%2Fcrypto/lists"}