Documentation
¶
Index ¶
- Variables
- func CombinedDecryptionAndVerification(ciphertext, key, nonce, signature []byte, publicKey ed25519.PublicKey) ([]byte, error)
- func CombinedEncryption(data []byte, privateKey ed25519.PrivateKey) ([]byte, []byte, []byte, error)
- func DecryptAES(key []byte, ct string) (string, error)
- func DecryptEd25519(ciphertextBase64, recipientPrivateKeyBase64 string) ([]byte, error)
- func DecryptEd25519ChaCha(nonce, ciphertext, signature []byte, encryptionKey []byte, ...) ([]byte, error)
- func DecryptRSA(encrypted []byte, privateKey *rsa.PrivateKey) []byte
- func DecryptWithAge(encryptedData []byte, identity *age.X25519Identity) ([]byte, error)
- func DecryptWithChaCha20Poly1305(nonce, ciphertext, key []byte) ([]byte, error)
- func EncryptAES(key []byte, plaintext string) (string, error)
- func EncryptEd25519(plaintext []byte, recipientPublicKeyBase64 string) (string, error)
- func EncryptEd25519ChaCha(plaintext []byte, encryptionKey []byte, signingPrivateKey ed25519.PrivateKey) ([]byte, []byte, []byte, error)
- func EncryptRSA(txt string) ([]byte, *rsa.PublicKey, *rsa.PrivateKey)
- func EncryptWithAge(data []byte, recipient *age.X25519Recipient) ([]byte, error)
- func EncryptWithChaCha20Poly1305(plaintext []byte, key []byte) ([]byte, []byte, error)
- func GenerateAgeKeyPair() (*age.X25519Identity, *age.X25519Recipient, error)
- func GenerateChaCha20Poly1305Key() ([]byte, error)
- func GenerateEd25519KeyPair() (publicKeyBase64, privateKeyBase64 string, err error)
- func GetEd25519PrivateKeyBase64(privateKey ed25519.PrivateKey) string
- func GetEd25519PrivateKeyHex(privateKey ed25519.PrivateKey) string
- func GetEd25519PublicKeyBase64(publicKey ed25519.PublicKey) string
- func GetEd25519PublicKeyHex(publicKey ed25519.PublicKey) string
- func GetPublicKeyFromPrivate(privateKeyBase64 string) (string, error)
- func Md5(txt string) string
- func SaveEd25519PrivateKey(privateKey ed25519.PrivateKey, filename string) error
- func SaveEd25519PublicKey(publicKey ed25519.PublicKey, filename string) error
- func SaveRSAPrivateKey(private *rsa.PrivateKey)
- func SaveRSAPublicKey(public *rsa.PublicKey)
- func Sha2(txt string) string
- func SignWithEd25519(message []byte, privateKey ed25519.PrivateKey) []byte
- func VerifyEd25519Signature(publicKey ed25519.PublicKey, message []byte, signature []byte) bool
Constants ¶
This section is empty.
Variables ¶
var (
AESIVKey = []byte("12345678901234567890123456789012") // 256位密钥
)
Functions ¶
func CombinedDecryptionAndVerification ¶ added in v1.0.79
func CombinedDecryptionAndVerification(ciphertext, key, nonce, signature []byte, publicKey ed25519.PublicKey) ([]byte, error)
CombinedDecryptionAndVerification 组合解密和签名验证
func CombinedEncryption ¶ added in v1.0.79
CombinedEncryption 结合Ed25519签名和ChaCha20-Poly1305加密
func DecryptEd25519 ¶ added in v1.0.79
DecryptEd25519 使用接收方的 Ed25519/X25519 私钥解密数据
参数:
- ciphertextBase64: Base64 编码的密文
- recipientPrivateKeyBase64: 接收方的私钥 (Base64 编码的 32 字节 Ed25519/X25519 私钥)
返回值:
- []byte: 解密后的明文数据
- error: 错误信息
func DecryptEd25519ChaCha ¶ added in v1.0.79
func DecryptEd25519ChaCha(nonce, ciphertext, signature []byte, encryptionKey []byte, signingPublicKey ed25519.PublicKey) ([]byte, error)
DecryptEd25519ChaCha decrypts and verifies data using ChaCha20-Poly1305 decryption with Ed25519 verification
func DecryptRSA ¶
func DecryptRSA(encrypted []byte, privateKey *rsa.PrivateKey) []byte
func DecryptWithAge ¶ added in v1.0.79
func DecryptWithAge(encryptedData []byte, identity *age.X25519Identity) ([]byte, error)
DecryptWithAge 使用Age对数据进行解密
func DecryptWithChaCha20Poly1305 ¶ added in v1.0.79
DecryptWithChaCha20Poly1305 使用ChaCha20-Poly1305对数据进行解密
func EncryptEd25519 ¶ added in v1.0.79
EncryptEd25519 使用接收方的 Ed25519/X25519 公钥加密数据 返回 Base64 编码的密文
参数:
- plaintext: 需要加密的明文数据
- recipientPublicKeyBase64: 接收方的公钥 (Base64 编码的 32 字节 Ed25519/X25519 公钥)
返回值:
- string: Base64 编码的密文
- error: 错误信息
func EncryptEd25519ChaCha ¶ added in v1.0.79
func EncryptEd25519ChaCha(plaintext []byte, encryptionKey []byte, signingPrivateKey ed25519.PrivateKey) ([]byte, []byte, []byte, error)
EncryptEd25519ChaCha combines ChaCha20-Poly1305 encryption with Ed25519 signature
func EncryptRSA ¶
func EncryptWithAge ¶ added in v1.0.79
func EncryptWithAge(data []byte, recipient *age.X25519Recipient) ([]byte, error)
EncryptWithAge 使用Age对数据进行加密
func EncryptWithChaCha20Poly1305 ¶ added in v1.0.79
EncryptWithChaCha20Poly1305 使用ChaCha20-Poly1305对数据进行加密
func GenerateAgeKeyPair ¶ added in v1.0.79
func GenerateAgeKeyPair() (*age.X25519Identity, *age.X25519Recipient, error)
GenerateAgeKeyPair 生成Age加密的密钥对
func GenerateChaCha20Poly1305Key ¶ added in v1.0.79
GenerateChaCha20Poly1305Key 生成ChaCha20-Poly1305密钥
func GenerateEd25519KeyPair ¶ added in v1.0.79
GenerateEd25519KeyPair 生成 Ed25519/X25519 密钥对 返回 Base64 编码的公钥和私钥
返回值:
- publicKeyBase64: Base64 编码的公钥 (32 字节)
- privateKeyBase64: Base64 编码的私钥 (32 字节)
- error: 错误信息
func GetEd25519PrivateKeyBase64 ¶ added in v1.0.79
func GetEd25519PrivateKeyBase64(privateKey ed25519.PrivateKey) string
GetEd25519PrivateKeyBase64 获取Ed25519私钥的Base64编码字符串表示
func GetEd25519PrivateKeyHex ¶ added in v1.0.79
func GetEd25519PrivateKeyHex(privateKey ed25519.PrivateKey) string
GetEd25519PrivateKeyHex 获取Ed25519私钥的十六进制字符串表示
func GetEd25519PublicKeyBase64 ¶ added in v1.0.79
GetEd25519PublicKeyBase64 获取Ed25519公钥的Base64编码字符串表示
func GetEd25519PublicKeyHex ¶ added in v1.0.79
GetEd25519PublicKeyHex 获取Ed25519公钥的十六进制字符串表示
func GetPublicKeyFromPrivate ¶ added in v1.0.80
GetPublicKeyFromPrivate 从私钥提取公钥
func SaveEd25519PrivateKey ¶ added in v1.0.79
func SaveEd25519PrivateKey(privateKey ed25519.PrivateKey, filename string) error
SaveEd25519PrivateKey 将Ed25519私钥保存到PEM格式文件
func SaveEd25519PublicKey ¶ added in v1.0.79
SaveEd25519PublicKey 将Ed25519公钥保存到PEM格式文件
func SaveRSAPrivateKey ¶
func SaveRSAPrivateKey(private *rsa.PrivateKey)
func SaveRSAPublicKey ¶
func SignWithEd25519 ¶ added in v1.0.79
func SignWithEd25519(message []byte, privateKey ed25519.PrivateKey) []byte
SignWithEd25519 使用Ed25519私钥对消息进行签名
Types ¶
This section is empty.