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

Export md5 function in src/utils/crypto.ts #305

Merged
merged 3 commits into from
Jun 9, 2022

Conversation

erhlee-bird
Copy link
Contributor

Export an additional md5 function in the crypto utility.

Useful when working with R2 and providing a MD5 hash for verification.

import { md5 } from "hono/utils/crypto";

...
const md5Digest = md5(body);
const object = await bucket.put(key, body, {md5: md5Digest});

It is worth noting, however, that "MD5 is not part of the WebCrypto standard but is supported in Cloudflare Workers for interacting with legacy systems that require MD5." 1

Export an additional `md5` function in the crypto utility.

Useful when working with R2 and providing a MD5 hash for verification.

```
import { md5 } from "hono/utils/crypto";

...
const md5Digest = md5(body);
const object = await bucket.put(key, body, {md5: md5Digest});
```
@yusukebe
Copy link
Member

yusukebe commented Jun 9, 2022

Hi @erhlee-bird !

Thank you for your PR. It's OK to export the md5 function. Could you write the test for md5 on src/utils/crypto.test.ts? Then, I'll merge it.

@erhlee-bird
Copy link
Contributor Author

Added the test and confirmed that it passes locally. Thanks for responding so quickly.

image

@yusukebe yusukebe merged commit d2a4b2d into honojs:master Jun 9, 2022
@erhlee-bird erhlee-bird deleted the patch-1 branch June 9, 2022 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants