Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve crypto docs #41

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions extensions/crypto/description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extension:
version: 1.0.0
language: C++
build: cmake
license: Apache-2.0
license: MIT
excluded_platforms: "windows_amd64_rtools;windows_amd64"
maintainers:
- rustyconover
Expand All @@ -15,7 +15,46 @@ repo:

docs:
hello_world: |
SELECT * from read_csv('seq 1 100 | grep 2 |');
-- Calculate the MD5 hash value of 'abcdef'
SELECT crypto_hash('md5', 'abcdef');
┌──────────────────────────────────┐
│ crypto_hash('md5', 'abcdef') │
│ varchar │
├──────────────────────────────────┤
│ e80b5017098950fc58aad83c8c14978e │
└──────────────────────────────────┘

-- Calculate a HMAC
SELECT crypto_hmac('sha2-256', 'secret key', 'secret message');
┌──────────────────────────────────────────────────────────────────┐
│ crypto_hmac('sha2-256', 'secret key', 'secret message') │
│ varchar │
├──────────────────────────────────────────────────────────────────┤
│ 2df792e08cefdc0ea9900c67c93cbe66b98231b829a5dccd3857a03baac35963 │
└──────────────────────────────────────────────────────────────────┘
extended_description: |
This extension, `crypto`, adds cryptographic hash functions and
the ability to calculate a HMAC to DuckDB's SQL engine.
`crypto` provides two functions:

- `crypto_hash` applies cryptographically secure hash functions
and returns the result as a hex encoded value.

- `crypto_hmac` calculates the HMAC using a secret key and a
specific hash function.

The supported hash functions are:
- `blake2b-512`
- `keccak224`
- `keccak256`
- `keccak384`
- `keccak512`
- `md4`
- `md5`
- `sha1`
- `sha2-224`
- `sha2-256`
- `sha2-384`
- `sha2-512`
- `sha3-224`
- `sha3-256`
- `sha3-384`
- `sha3-512`
4 changes: 2 additions & 2 deletions extensions/crypto/docs/function_descriptions.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function,description,comment,example
crypto_hash,"Calculate the value of a hash function","","select crypto_hash('md5', 'test');"
crypto_hmac,"Calculate a HMAC value","","select crypto_hmac('sha2-256', 'secret key', 'secret message');"
"crypto_hash","Apply a cryptographic hash function specified as the first argument to the data supplied as the second argument.","","SELECT crypto_hash('md5', 'test');"
"crypto_hmac","Calculate a HMAC value","","SELECT crypto_hmac('sha2-256', 'secret key', 'secret message');"
Loading