crypto

package
v0.0.0-...-2c9ad6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(n int) string

GenerateKey creates random string key

func HashPassword

func HashPassword(password string, cost int) ([]byte, error)

HashPassword returns hash from raw string

func ValidateNewPassword

func ValidateNewPassword(password string) error

ValidateNewPassword Validate new password is valid

func VerifyPassword

func VerifyPassword(password, hash string) bool

VerifyPassword check if pasword matches hash

Types

type PEM

type PEM struct {
	Host        string
	ValidFrom   string
	ValidFor    time.Duration
	IsCA        bool
	RsaBits     int
	EcdsaCurve  string
	IsGenerated bool
	Template    x509.Certificate
	Priv        interface{}
}

func NewPEM

func NewPEM(host string) *PEM

NewPEM creates new PEM

host       = flag.String("host", "", "Comma-separated hostnames and IPs to generate a certificate for")
validFrom  = flag.String("start-date", "", "Creation date formatted as Jan 1 15:04:05 2011")
validFor   = flag.Duration("duration", 365*24*time.Hour, "Duration that certificate is valid for")
isCA       = flag.Bool("ca", false, "whether this cert should be its own Certificate Authority")
rsaBits    = flag.Int("rsa-bits", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set")
ecdsaCurve = flag.String("ecdsa-curve", "", "ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521")

PEM{
	Host:        *host,
	ValidFrom:   *validFrom,
	ValidFor:    *validFor,
	IsCA:        false,
	RsaBits:     *rsaBits,
	EcdsaCurve:  *ecdsaCurve,
	IsGenerated: false,
	Template:    x509.Certificate{},
}

err := p.Generate("cert.pem", "key.pem")
if err != nil {
	panic(err)
}

func (*PEM) Create

func (p *PEM) Create() error

func (*PEM) Generate

func (p *PEM) Generate(cert, key string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL