utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(privateKeyFile, ciphertext string, types string) (plaintext string, err error)

Decrypt 使用私钥解密数据

func DecryptOAEP

func DecryptOAEP(privateKeyFile, ciphertext string) (plaintext string, err error)

DecryptOAEP 使用私钥解密数据

func DecryptPKCS1v15

func DecryptPKCS1v15(privateKeyFile, ciphertext string) (plaintext string, err error)

DecryptPKCS1v15 使用私钥解密数据

func Encrypt

func Encrypt(privateKeyFile, ciphertext string, types string) (plaintext string, err error)

Encrypt 使用公钥加密数据

func EncryptOAEP

func EncryptOAEP(publicKeyFile string, content string) (ciphertext string, err error)

EncryptOAEP 使用公钥加密数据

func EncryptPKCS1v15

func EncryptPKCS1v15(publicKeyFile string, content string) (ciphertext string, err error)

EncryptPKCS1v15 使用公钥加密数据

func EncryptPassword

func EncryptPassword(password string, salt string) (string, error)

func EncryptString

func EncryptString(data string) (encrypt string, err error)

EncryptString encrypts `data` using MD5 algorithms.

func GenerateKeyPair

func GenerateKeyPair(bits int, privateKeyFile string, publicKeyFile string) (err error)

GenerateKeyPair 生成RSA密钥对

func IpInBlackListRange

func IpInBlackListRange(ip string, ipList []string) (result bool)

IpInBlackListRange 判断IP是否在黑名单

func ParseIpRange

func ParseIpRange(cidr string) ([]string, error)

ParseIpRange 用于将以 "," 分割的多个 CIDR 范围字符串解析为 CIDR 数组。 如果一个 CIDR 范围是以 "-" 分割的两个 IP 地址,那么我们会使用 binaryToInt 和 intToIP 函数将它们转换为整数并再次转换为 CIDR 字符串, 并将其加入到 CIDR 数组中。

func ParsePrivateKeyFromPEM

func ParsePrivateKeyFromPEM(pemBytes []byte) (privateKey *rsa.PrivateKey, err error)

ParsePrivateKeyFromPEM 从 PEM 格式的字节切片中解析 RSA 私钥

func ParsePublicKeyFromPEM

func ParsePublicKeyFromPEM(pemBytes []byte) (publicKey *rsa.PublicKey, err error)

ParsePublicKeyFromPEM 从 PEM 格式的字节切片中解析 RSA 公钥

func ReplaceTemplate

func ReplaceTemplate(content string, variable map[string]interface{}) (result string, err error)

func SavePrivateKeyToFile

func SavePrivateKeyToFile(privateKey *rsa.PrivateKey, filename string) (err error)

SavePrivateKeyToFile 将 RSA 私钥保存到文件

func SavePublicKeyToFile

func SavePublicKeyToFile(publicKey *rsa.PublicKey, filename string) (err error)

SavePublicKeyToFile 将 RSA 公钥保存到文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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