Documentation
¶
Overview ¶
Security related tools.
Index ¶
- Variables
- func Decrypt(key []byte, data []byte) ([]byte, error)
- func Decrypt64(key []byte, data string) ([]byte, error)
- func Encrypt(key []byte, data []byte) ([]byte, error)
- func Encrypt64(key []byte, data []byte) (string, error)
- func GenerateSecureRandom(length uint32) []byte
- func GenerateSecureRandomString(length uint32) string
- func GenerateSecureRandomStringWithChars(length uint32, chars []rune) string
- type Argon2IdHashGenerator
- func (i Argon2IdHashGenerator) GenerateHashBase64(target string) (string, error)
- func (i Argon2IdHashGenerator) GenerateHashBytes(target string) []byte
- func (i Argon2IdHashGenerator) GenerateHashWithSalt(targetBytes []byte, saltBytes []byte) []byte
- func (i Argon2IdHashGenerator) GenerateKeyFromBytes(targetBytes []byte, length uint32, saltBytes []byte) []byte
- func (i Argon2IdHashGenerator) Verify(target []byte, hashed []byte) bool
- func (i Argon2IdHashGenerator) VerifyBase64(target string, base64Hash string) (bool, error)
- type EncryptionService
- type EncryptionServiceImpl
- type HashGenerator
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultArgon2Id = Argon2IdHashGenerator{ Memory: 64 * 1024, Iterations: 3, Parallelism: 2, SaltLength: 16, Keylength: 32, Pepper: nil, }
An Argon2IdHashGenerator with default settings which can be used as is.
Functions ¶
func GenerateSecureRandom ¶
Utility to generate a secure random bytes.
func GenerateSecureRandomString ¶ added in v0.0.7
func GenerateSecureRandomStringWithChars ¶ added in v0.0.7
Types ¶
type Argon2IdHashGenerator ¶
type Argon2IdHashGenerator struct { // Amount of memory to use Memory uint32 // Number of argon2id iterations Iterations uint32 // Amount of threads or parallelism. Parallelism uint8 // Length of the salt. SaltLength uint32 // Length of the resulting key. Keylength uint32 // If set, this value is appended to the password/target before hashing. Pepper []byte }
Use to generate hashes using argon2id.
func (Argon2IdHashGenerator) GenerateHashBase64 ¶
func (i Argon2IdHashGenerator) GenerateHashBase64(target string) (string, error)
Generates the hash of a string and returns the base64 encoded hash.
func (Argon2IdHashGenerator) GenerateHashBytes ¶
func (i Argon2IdHashGenerator) GenerateHashBytes(target string) []byte
Generates a hash of the specified string.
func (Argon2IdHashGenerator) GenerateHashWithSalt ¶
func (i Argon2IdHashGenerator) GenerateHashWithSalt(targetBytes []byte, saltBytes []byte) []byte
Genrate bytes with the specified salt. The salt is the first n bytes of the returned value
func (Argon2IdHashGenerator) GenerateKeyFromBytes ¶
func (i Argon2IdHashGenerator) GenerateKeyFromBytes(targetBytes []byte, length uint32, saltBytes []byte) []byte
Generates the raw hash without including the salt in the output bytes.
func (Argon2IdHashGenerator) Verify ¶
func (i Argon2IdHashGenerator) Verify(target []byte, hashed []byte) bool
Verifies the specified target bytes against the hash.
func (Argon2IdHashGenerator) VerifyBase64 ¶
func (i Argon2IdHashGenerator) VerifyBase64(target string, base64Hash string) (bool, error)
Verifies the specified target against a hash encoded in base64.
type EncryptionService ¶
type EncryptionService interface { Encrypt(data []byte) ([]byte, error) Decrypt(data []byte) ([]byte, error) Encrypt64(data string) (string, error) Decrypt64(data string) ([]byte, error) }
func NewEncryptionService ¶ added in v0.0.7
func NewEncryptionService(key []byte) EncryptionService
type EncryptionServiceImpl ¶ added in v0.0.7
type EncryptionServiceImpl struct {
// contains filtered or unexported fields
}
func (EncryptionServiceImpl) Decrypt ¶ added in v0.0.7
func (s EncryptionServiceImpl) Decrypt(data []byte) ([]byte, error)
func (EncryptionServiceImpl) Decrypt64 ¶ added in v0.0.7
func (s EncryptionServiceImpl) Decrypt64(data string) ([]byte, error)
Click to show internal directories.
Click to hide internal directories.