31 lines
502 B
Go
31 lines
502 B
Go
package parameters
|
|
|
|
import "crypto/rand"
|
|
|
|
type PasswordParams struct {
|
|
Memory uint32
|
|
Iterations uint32
|
|
Parallelism uint8
|
|
SaltLength uint32
|
|
KeyLength uint32
|
|
}
|
|
|
|
func GetPasswordParams() *PasswordParams {
|
|
return &PasswordParams{
|
|
Memory: 64 * 1024,
|
|
Iterations: 3,
|
|
Parallelism: 2,
|
|
SaltLength: 16,
|
|
KeyLength: 32,
|
|
}
|
|
}
|
|
|
|
func GenerateRandomBytes(n uint32) ([]byte, error) {
|
|
b := make([]byte, n)
|
|
_, err := rand.Read(b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return b, nil
|
|
}
|