Using crypto in convex functions
i have this utility function...
util.ts, stored outside/inside convex folder, same issues.
which i want to use in a query like this
This does not work because the code is running on the client side and the crypto module only exists on the sever, this might be a silly question but where can i write the sever code to encrypt my messages.
5 Replies
Convex actions support web crypto, not node.js style crypto
MDN Web Docs
Web Crypto API - Web APIs | MDN
The Web Crypto API is an interface allowing a script to use cryptographic primitives in order to build systems using cryptography.
and there's a recent thread, one sec...
https://discord.com/channels/1019350475847499849/1195116504509857842/1197275006527361136
this article demonstrates using web crypto apis to do AES encryption: https://medium.com/@tony.infisical/guide-to-web-crypto-api-for-encryption-decryption-1a2c698ebc25
Medium
Guide to Web Crypto API for encryption/decryption
Depending on your environment and requirements, the Web Crypto API may be needed required or suitable to perform cryptographic operations…
Thank you