Documentation ¶
Overview ¶
Package crypto provides cryptographic solutions for the user package. The main responsibility to define one or more hashing methods to store passwords and other sensitive data securely.
Index ¶
- Constants
- Variables
- func GenerateCurve() (string, error)
- func MarshalECPublicKey(publicKey ecdsa.PublicKey) string
- func Padding(key string, length int) (string, error)
- func RandomString(n int) string
- func UnmarshalECPublicKey(compressed string) (ecdsa.PublicKey, error)
- type AES128
- type Descriptor
- type Encrypter
Constants ¶
View Source
const ( // Argon2id defines a type for argon2 hashing as enum Argon2id uint8 = iota )
View Source
const (
// DefaultSaltLength defines the default length when salt generation happening
DefaultSaltLength = 18
)
Variables ¶
View Source
var ( ErrAES128Length = errors.New("plaintext length should be 16") ErrInternalDecryptLength = errors.New("decrypt data not formatted properly") ErrKeyLength = errors.New("key should be at least 1 character") )
errors
Functions ¶
func GenerateCurve ¶ added in v0.4.0
func MarshalECPublicKey ¶
MarshalECPublicKey accept an ecdsa.PublicKey and marshal it to a compressed shareable format
func RandomString ¶
RandomString generates random bytes and returns as string
Types ¶
type AES128 ¶
type AES128 struct{}
type Descriptor ¶
type Descriptor interface { // Hash should be able to do a hashing on an arbitrary string Hash(str, salt string) string // Verify should be able to verify a previously created hash // by compering with the arbitrary string Verify(str, salt, hash string) error // GenerateToken should be able to generate a token // which hardened with the hashing algorithm GenerateToken(tokenSalt string) string }
Descriptor defines what a hashing implementation should be able to do
func Get ¶
func Get(typ uint8) (Descriptor, error)
Get will return a hash algorithm for use, or returns error
Click to show internal directories.
Click to hide internal directories.