blob: c97723d75b65debe5f3b1f30336a465d2e105669 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package byspel
import de.mkammerer.argon2.Argon2Factory
import java.nio.charset.StandardCharsets
object PasswordHash {
private val argon2 = Argon2Factory.create()
/** Salt and hash a password. */
def protect(plain: String): String =
argon2.hash(
10, // iterations
65536, // memory
1, // parallelism
plain, // password
StandardCharsets.UTF_8
)
def verify(plain: String, hashed: String): Boolean =
argon2.verify(hashed, plain)
}
|