crypt

package
v0.33.12 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const TotpLen = 6

Variables

View Source
var (
	SkipVerify = false
)

Functions

func AddTrustedCert

func AddTrustedCert(vkey string, fp []byte)

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(origData, key []byte) ([]byte, error)

func Blake2b

func Blake2b(s string) string

Blake2b Generate 64-bit BLAKE2b-256 strings

func BuildTotpUri added in v0.33.12

func BuildTotpUri(issuer, accountName, secret string) string

func ComputeHMAC

func ComputeHMAC(passwd string, timestamp int64, randomDataPieces ...[]byte) []byte

ComputeHMAC Get HMAC value

func DecryptBytes

func DecryptBytes(enc []byte, keyStr string) ([]byte, error)

DecryptBytes AES-GCM

func DecryptStringWithPrivateKey

func DecryptStringWithPrivateKey(base64Cipher string) (string, error)

func DecryptWithPrivateKey

func DecryptWithPrivateKey(base64Cipher string) ([]byte, error)

func EncryptBytes

func EncryptBytes(data []byte, keyStr string) ([]byte, error)

EncryptBytes AES-GCM

func FNV1a64

func FNV1a64(parts ...string) string

func GenerateTOTPSecret

func GenerateTOTPSecret() (string, error)

func GenerateUUID added in v0.33.12

func GenerateUUID(nameParts ...string) uuid.UUID

func GetCert

func GetCert() tls.Certificate

func GetCertCfg added in v0.33.12

func GetCertCfg() *tls.Config

func GetCertFingerprint

func GetCertFingerprint(certificate tls.Certificate) []byte

func GetFakeDomainName added in v0.33.12

func GetFakeDomainName() string

func GetHMAC added in v0.33.12

func GetHMAC(passwd string, data ...[]byte) []byte

func GetPublicKeyPEM

func GetPublicKeyPEM() (string, error)

func GetRSAPublicKeyPEM added in v0.33.12

func GetRSAPublicKeyPEM() (string, error)

func GetRandomString

func GetRandomString(l int, id ...int) string

GetRandomString 生成指定长度的随机密钥,支持可选传入id

func GetTOTPCode

func GetTOTPCode(secret string) (string, int64, error)

func GetUUID added in v0.33.12

func GetUUID() uuid.UUID

func InitTls

func InitTls(customCert tls.Certificate)

func IsValidTOTPSecret added in v0.33.12

func IsValidTOTPSecret(secret string) bool

func Md5

func Md5(s string) string

Md5 Generate 32-bit MD5 strings

func NewTlsClientConn

func NewTlsClientConn(conn net.Conn) net.Conn

func NewTlsServerConn

func NewTlsServerConn(conn net.Conn) net.Conn

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding Completion when the length is insufficient

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) (error, []byte)

PKCS5UnPadding Remove excess

func PrintTOTPCode

func PrintTOTPCode(secret string)

func PrintTOTPSecret

func PrintTOTPSecret()

func ReadClientHello

func ReadClientHello(clientConn net.Conn, prefix []byte) (helloInfo *tls.ClientHelloInfo, rawData []byte, err error)

func ValidateTOTPCode

func ValidateTOTPCode(secret, code string) (bool, error)

Types

type LoginPayload

type LoginPayload struct {
	Nonce     string `json:"n"`
	Timestamp int64  `json:"t"`
	Password  string `json:"p"`
}

func ParseLoginPayload

func ParseLoginPayload(base64Cipher string) (*LoginPayload, error)

type ReadOnlyConn

type ReadOnlyConn struct {
	// contains filtered or unexported fields
}

func (*ReadOnlyConn) Close

func (c *ReadOnlyConn) Close() error

func (*ReadOnlyConn) LocalAddr

func (c *ReadOnlyConn) LocalAddr() net.Addr

func (*ReadOnlyConn) Read

func (c *ReadOnlyConn) Read(p []byte) (int, error)

func (*ReadOnlyConn) RemoteAddr

func (c *ReadOnlyConn) RemoteAddr() net.Addr

func (*ReadOnlyConn) SetDeadline

func (c *ReadOnlyConn) SetDeadline(_ time.Time) error

func (*ReadOnlyConn) SetReadDeadline

func (c *ReadOnlyConn) SetReadDeadline(_ time.Time) error

func (*ReadOnlyConn) SetWriteDeadline

func (c *ReadOnlyConn) SetWriteDeadline(_ time.Time) error

func (*ReadOnlyConn) Write

func (c *ReadOnlyConn) Write(_ []byte) (int, error)

type SniffConn

type SniffConn struct {
	net.Conn

	Rb []byte
	// contains filtered or unexported fields
}

func NewSniffConn

func NewSniffConn(conn net.Conn, maxSize int) *SniffConn

func (*SniffConn) Bytes

func (s *SniffConn) Bytes() []byte

func (*SniffConn) Read

func (s *SniffConn) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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