eod commit
This commit is contained in:
16
app/src/database/db.v
Normal file
16
app/src/database/db.v
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
module database
|
||||||
|
|
||||||
|
import fleximus.argon2
|
||||||
|
import rand
|
||||||
|
|
||||||
|
pub struct Crypto {}
|
||||||
|
|
||||||
|
pub fn Crypto.hash_password(password string) !string {
|
||||||
|
salt := rand.bytes(16) or { return error('failed to generate salt: ${err}') }
|
||||||
|
hash := argon2.hash(password.bytes(), salt) or { return error('argon2 hash failed: ${err}') }
|
||||||
|
return hash
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn Crypto.hash_verify(password string, hash string) !bool {
|
||||||
|
return argon2.verify(hash, password.bytes()) or { return error('argon2 verify failed: ${err}') }
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ module main
|
|||||||
import os
|
import os
|
||||||
import veb
|
import veb
|
||||||
import util
|
import util
|
||||||
// import app.src.util // IDE display version
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user