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

What is the benefit of converting to Hex and not keeping it the same as native Sodium? #36

Closed
KarimFikani opened this issue Jul 6, 2020 · 2 comments
Assignees
Labels
question If you simply want to ask a question, then use this

Comments

@KarimFikani
Copy link

I saw it in the comment and so is in the code but I don't understand the reason behind the conversion?

"The reason for this is that the Lazy interface defaults to converting everything to hexadecimal whereas the Native interface assumes everything is non-hexadecimal"

Is there a benefit? Wouldn't the conversion add unnecessary overhead?

@gurpreet- gurpreet- self-assigned this Jul 6, 2020
@gurpreet- gurpreet- added the question If you simply want to ask a question, then use this label Jul 6, 2020
@gurpreet-
Copy link
Contributor

Hi @KarimFikani,

The benefit of encoding is that you can store the encoded string safely in a database or anywhere. It is truly lazy. Unfortunately, yes, extra overhead would be added but I imagine this would be insignificant. Without encoding the byte array you are at risk of doing something risky to the byte array.

Plus, it is good to have a consistent encoding strategy throughout your project so Lazysodium stuck to hex encoding as its default. There was a MessageEncoder interface added to Lazysodium Android 4.1.1 so you can write your own encoder if you want https://github.com/terl/lazysodium-java/pull/70/files (Base64, Base32, etc)

@KarimFikani
Copy link
Author

ok thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question If you simply want to ask a question, then use this
Projects
None yet
Development

No branches or pull requests

2 participants