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

Support for encrypting numbers #137

Open
harunsmrkovic opened this issue Dec 9, 2024 · 1 comment
Open

Support for encrypting numbers #137

harunsmrkovic opened this issue Dec 9, 2024 · 1 comment

Comments

@harunsmrkovic
Copy link

Hey folks,

I recently started using this for a hobby project and noticed that it is possible to encrypt Strings only.

Error: encryption enabled for field amount of unsupported type Float: only String fields can be encrypted.

Is there some inherent plugin/cryptography limitation to encrypting numbers, or was this just never a priority to implement?

If someone could give me a couple of hints around this I'd love to take a stab at implementing support for it.

@franky47
Copy link
Member

franky47 commented Dec 9, 2024

There is no technical limitation AFAIK, AES-GCM-256 would work fine on the IEEE-754 float64 data format used by JavaScript to store numbers (I did this a while back for another project, source), with proper padding (float64 is 64 bits, so we'd need a constant 64 bits of padding for a 128 bit AES block size).

The main challenge in implementing this (and/or other data types) is how to define the data format that is being encrypted: how to go from a JavaScript variable to an array of bytes to encrypt, and on decryption how to go back from the decrypted array of bytes back into a JavaScript data type.

For SQL-based schemas, I suppose we could use the schema metadata to know what kind of processing to do, but I'm not sure how that would translate in MongoDB / NoSQL schemas.

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

No branches or pull requests

2 participants