File: profile.go

package info (click to toggle)
golang-github-go-crypt-crypt 0.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 516 kB
  • sloc: makefile: 4
file content (28 lines) | stat: -rw-r--r-- 858 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package argon2

import (
	"github.com/go-crypt/crypt/algorithm"
)

// Profile represents a hashing profile for Argon2Hash.
type Profile int

const (
	// ProfileRFC9106LowMemory is the RFC9106 low memory profile.
	ProfileRFC9106LowMemory Profile = iota

	// ProfileRFC9106Recommended is the RFC9106 recommended profile.
	ProfileRFC9106Recommended
)

// Hasher returns the argon2.Profile parameters as an argon2.Hasher.
func (p Profile) Hasher() *Hasher {
	switch p {
	case ProfileRFC9106LowMemory:
		return &Hasher{variant: VariantID, t: 3, p: 4, m: 64 * 1024, k: KeyLengthDefault, s: algorithm.SaltLengthDefault}
	case ProfileRFC9106Recommended:
		return &Hasher{variant: VariantID, t: IterationsDefault, p: ParallelismDefault, m: MemoryDefault, k: KeyLengthDefault, s: algorithm.SaltLengthDefault}
	default:
		return ProfileRFC9106Recommended.Hasher()
	}
}