security

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultLength is the default length of the generated OTP code.
	DefaultLength = 6
	// DefaultTimePeriod is the default time period for the TOTP.
	DefaultTimePeriod = 30
)

Variables

This section is empty.

Functions

func CheckPasswordConfirm added in v1.5.1

func CheckPasswordConfirm(password, confirm []byte) bool

CheckPasswordConfirm checks two byte array if the content is the same.

func GenerateOTPCode

func GenerateOTPCode(opts GenerateOptions) (string, int64, error)

GenerateOTPCode generates an N digit TOTP from the secret Token.

func UnsecureSHA1

func UnsecureSHA1(text string) []byte

UnsecureSHA1 is not secure, but makes a fixed length password. With v2, I'm planning to move away from it, but that would break all existing vaults, so I have to be careful and make sure a proper migration script/function exists.

Types

type GenerateOptions added in v1.9.1

type GenerateOptions struct {
	Token      string
	When       time.Time
	Length     uint
	Algorithm  algo.Algorithm
	TimePeriod int64
}

GenerateOptions is the option list for the GenerateOTPCode function.

type OTPError

type OTPError struct {
	Message string
}

OTPError is an error describing an error during generation.

func (OTPError) Error

func (e OTPError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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