crypt

package
v0.29.16 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SkipVerify = false
)

Functions

func AddTrustedCert

func AddTrustedCert(vkey string, fp []byte)

func AesDecrypt

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

de

func AesEncrypt

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

en

func Blake2b

func Blake2b(s string) string

Generate 64-bit BLAKE2b-256 strings

func ComputeHMAC

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

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 GetCert

func GetCert() tls.Certificate

func GetCertFingerprint

func GetCertFingerprint(certificate tls.Certificate) []byte

func GetPublicKeyPEM

func GetPublicKeyPEM() (string, error)

func GetRandomString

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

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

func GetTOTPCode

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

func InitTls

func InitTls(customCert tls.Certificate)

func Md5

func Md5(s string) string

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

Completion when the length is insufficient

func PKCS5UnPadding

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

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