crypt

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncryptedData

type EncryptedData struct {
	Salt  []byte // Argon2id加密的随机值,配合密码计算出key (base64)
	Seal  []byte // GCM加密后的内容 (base64)
	Nonce []byte // GCM加密随机数 (base64)
}

EncryptedData 加密后的信息

type Encryption

type Encryption struct {
	Memory      int
	Iterations  int // 遍历次数
	Parallelism int // 并行数 0~255
	SaltLength  int // 盐长度
	KeyLength   int // 密钥长度为16,24,32
}

Encryption 私钥加密配置信息

func New

func New() *Encryption

New 获取默认配置

func (Encryption) Argon2idKey

func (s Encryption) Argon2idKey(password string, salt []byte) []byte

Argon2idKey Argon2id密钥生成

func (Encryption) Argon2idSalt

func (s Encryption) Argon2idSalt() []byte

Argon2idSalt Argon2id随机盐生成

func (Encryption) DecryptAESGCM

func (s Encryption) DecryptAESGCM(key, data []byte) ([]byte, error)

DecryptAESGCM AESGCM对称解密

func (Encryption) DecryptArgon2id

func (s Encryption) DecryptArgon2id(password string, data EncryptedData) ([]byte, error)

DecryptArgon2id 提供密码,加密信息和加密配置,返回私钥

func (Encryption) EncryptAESGCM

func (s Encryption) EncryptAESGCM(key, data []byte) ([]byte, error)

EncryptAESGCM AESGCM对称加密

func (Encryption) EncryptArgon2id

func (s Encryption) EncryptArgon2id(password string, data []byte) (EncryptedData, error)

EncryptArgon2id 通过password派生出的key加密私钥

Jump to

Keyboard shortcuts

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