cryptext

package
v0.0.594 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const LatestPassHashVersion = 5

Variables

This section is empty.

Functions

func BytesSha256

func BytesSha256(v []byte) string

func DecryptAESSimple

func DecryptAESSimple(password []byte, encText string) ([]byte, error)

func EncryptAESSimple

func EncryptAESSimple(password []byte, data []byte, rounds int) (string, error)

func PronouncablePassword

func PronouncablePassword(len int) string

func PronouncablePasswordExt

func PronouncablePasswordExt(rng io.Reader, pwlen int) (string, float64)

func PronouncablePasswordSeeded

func PronouncablePasswordSeeded(seed int64, len int) string

func StrSha256

func StrSha256(v string) string

Types

type PassHash

type PassHash string

PassHash - [v0]: plaintext password ( `0|...` ) // simple, used to write PW's directly in DB - [v1]: sha256(plaintext) // simple hashing - [v2]: seed | sha256<seed>(plaintext) // add seed - [v3]: seed | sha256<seed>(plaintext) | [hex(totp)] // add TOTP support - [v4]: bcrypt(plaintext) | [hex(totp)] // use proper bcrypt - [v5]: bcrypt(sha512(plaintext)) | [hex(totp)] // hash pw before bcrypt (otherwise max pw-len = 72)

func HashPassword

func HashPassword(plainpass string, totpSecret []byte) (PassHash, error)

func HashPasswordV0

func HashPasswordV0(plainpass string) (PassHash, error)

func HashPasswordV1

func HashPasswordV1(plainpass string) (PassHash, error)

func HashPasswordV2

func HashPasswordV2(plainpass string) (PassHash, error)

func HashPasswordV3

func HashPasswordV3(plainpass string, totpSecret []byte) (PassHash, error)

func HashPasswordV4

func HashPasswordV4(plainpass string, totpSecret []byte) (PassHash, error)

func HashPasswordV5

func HashPasswordV5(plainpass string, totpSecret []byte) (PassHash, error)

func (PassHash) Change

func (ph PassHash) Change(newPlainPass string) (PassHash, error)

func (PassHash) ClearTOTP

func (ph PassHash) ClearTOTP() (PassHash, error)

func (PassHash) Data

func (ph PassHash) Data() (_version int, _seed []byte, _payload []byte, _totp bool, _totpsecret []byte, _valid bool)

func (PassHash) HasTOTP

func (ph PassHash) HasTOTP() bool

func (PassHash) NeedsPasswordUpgrade

func (ph PassHash) NeedsPasswordUpgrade() bool

func (PassHash) String

func (ph PassHash) String() string

func (PassHash) Upgrade

func (ph PassHash) Upgrade(plainpass string) (PassHash, error)

func (PassHash) Valid

func (ph PassHash) Valid() bool

func (PassHash) Verify

func (ph PassHash) Verify(plainpass string, totp *string) bool

func (PassHash) WithTOTP

func (ph PassHash) WithTOTP(totpSecret []byte) (PassHash, error)

Jump to

Keyboard shortcuts

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