Skip to content

Commit

Permalink
feat: use base58 for content ids
Browse files Browse the repository at this point in the history
base58( blake3(content) )[..len]
  • Loading branch information
ozwaldorf committed Oct 9, 2024
1 parent 424f962 commit bce4fc8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ tinytemplate = "1.2"
serde_json = "1.0"
humanize-bytes = "1.0"
humantime = "2.1"
bs58 = "0.5"
blake3 = "1.5"

2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn handle_put(mut req: Request) -> Result<Response, Error> {
let filename = url.path_segments().unwrap().last();

// Hash content and use it for the id
let hash = blake3::hash(&body).to_hex();
let hash = bs58::encode(blake3::hash(&body).as_bytes()).into_string();
let id = &hash[..ID_LENGTH];

let kv = fastly::kv_store::KVStore::open(KV_STORE)?.expect("kv store to exist");
Expand Down

0 comments on commit bce4fc8

Please sign in to comment.