Documentation
¶
Index ¶
- func TextAesDecrypt(cipherText, key string) (string, error)
- func TextAesEncrypt(plainText, key string) (string, error)
- func TextDecrypt(priv *PrivateKey, ciphertext []byte) ([]byte, error)
- func TextEncrypt(pub *PublicKey, plaintext []byte) ([]byte, error)
- func TextVerify(plaintext []byte, decryptedHash []byte) bool
- type KeyPair
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TextAesDecrypt ¶
TextAesDecrypt 使用AES-CFB模式解密一个经过URL安全Base64编码的字符串。 它接受一个密文字符串和一个密钥,返回解密后的明文字符串和可能的错误。
func TextAesEncrypt ¶
TextAesEncrypt 使用AES-CFB模式加密文本。 它接受一个明文字符串和一个密钥(16、24或32字节), 返回一个经过URL安全的Base64编码的密文字符串和可能的错误。
func TextDecrypt ¶
func TextDecrypt(priv *PrivateKey, ciphertext []byte) ([]byte, error)
TextDecrypt 使用私钥解密密文。
func TextEncrypt ¶
TextEncrypt 使用公钥对明文进行加密。 注意:这是一个基础的RSA实现,没有使用填充方案(如OAEP), 在生产环境中,推荐使用 `crypto/rsa` 包以获得更高的安全性。
func TextVerify ¶
TextVerify 验证明文的哈希值是否与解密后的哈希值匹配。 这个函数适用于签名验证场景,即用公钥解密签名,然后与原文哈希比较。
Types ¶
Click to show internal directories.
Click to hide internal directories.