-
Notifications
You must be signed in to change notification settings - Fork 9
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
Some suggestions about the library API #3
Comments
Hi @Fi5t , I'm very glad that my library is helpful for you. Thanks so much for trying it out and the suggestions :) Absolutely happy to review pull-requests for all of these (ideally a separate one for each point). The suggested changes look very sensible! 1. Sounds great. And it seems that this improvement is even applicable to the underlying argon2 library. See
The proper fix would be to update it there and adding the type to the 2. Yes, more convenience is always good. I'd suggest that we go all the way and have each choice ( 3. I am not sure what you mean with reflection. I'd suggest to add a |
I think that the core agron2 library is very "low-level" and it can make sense for such types of libraries API. But libraries intended to the client code need to have a "high-level" API. So, my suggestion about the simplification of the Here is my approach: private val hashModeRegex = Regex("""argon2(i?d?)""")
....
return argon2instance.verify(
parseHashMode(hashAsString),
hashAsString,
passphraseOrPin
)
....
private fun parseHashMode(encodedHash: String): Argon2Mode {
val res = hashModeRegex.find(encodedHash)
return when (res?.value) {
"argon2i" -> Argon2Mode.ARGON2_I
"argon2d" -> Argon2Mode.ARGON2_D
"argon2id" -> Argon2Mode.ARGON2_ID
else -> throw BadHashException()
}
} Decoding a hash to Argon2KtResult is not a mission-critical feature for me. It would be nice to have, no more. |
Sounds good. Just one quick suggestions, by using I'm also happy with just three |
Hello! I'm really glad to see an Android version of the Argon2 library. I wanted to do it myself, but I haven't found enough time for it. Thanks for having done it for me 😉
However, when I started using this library I found out, that some API weren't very convenient to use. For instance:
mode
parameter to theverify()
method looks redundant because it can be elicited from a hash.verify()
method accepts only the string representation of the hash. It would be better to add an additional version of this method that would accept the byte array representation of the hash. It's very convenient to use it when reading hash from a file.Argon2KtResult
from the String/ByteArray representation. I have no idea how to do it now without using reflection.Maybe I'll face some other things later, but these things are the most important ones for me. I understand that you may not have time to make these API changes, but I can send you PR with my own implementation. What do you think?
The text was updated successfully, but these errors were encountered: