Documentation
¶
Index ¶
- Constants
- func BcryptCheck(password, hash string) bool
- func BcryptHash(password string) string
- func EcdsaDecrypt(privateKey *ecdsa.PrivateKey, ciphertext []byte) ([]byte, error)
- func EcdsaEncrypt(publicKey *ecdsa.PublicKey, message []byte) ([]byte, error)
- func EcdsaGenerateKey() (string, string, error)
- func EcdsaGenerateSignature(privateKeyStr, hashStr string) (string, error)
- func EcdsaVerifySignature(publicKeyStr, hashStr, signatureStr string) (bool, error)
- func GenerateRandomAESKey(keySize int) ([]byte, error)
- func GenerateRsaKeys() (string, string)
- func Md5v(str string, salt string) string
- func Md5vMulti(str string, salt string, iteration int) string
- func Sha256v(str string, salt string) string
- type AES
- type CBC
- func (c *CBC) AESDecrypt(ciphertext []byte, key []byte, iv ...byte) (plaintext []byte, err error)
- func (c *CBC) AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
- func (c *CBC) AESEncrypt(plaintext []byte, key []byte, iv ...byte) (ciphertext []byte, err error)
- func (c *CBC) AESEncryptHexString(plaintextHex string, keyHex string, ivHex string) (ciphertextHex string, err error)
- type CFB
- func (c *CFB) AESDecrypt(ciphertext []byte, key []byte, iv ...byte) (plaintext []byte, err error)
- func (c *CFB) AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
- func (c *CFB) AESEncrypt(plaintext []byte, key []byte, iv ...byte) (ciphertext []byte, err error)
- func (c *CFB) AESEncryptHexString(plaintextHex string, keyHex string, ivHex string) (ciphertextHex string, err error)
- type GCM
- func (g *GCM) AESDecrypt(ciphertext []byte, key []byte, iv ...byte) (plaintext []byte, err error)
- func (g *GCM) AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
- func (g *GCM) AESEncrypt(plaintext []byte, key []byte, iv ...byte) (ciphertext []byte, err error)
- func (g *GCM) AESEncryptHexString(plaintextHex string, keyHex string, ivHex string) (ciphertextHex string, err error)
Constants ¶
View Source
const (
RSA_KEY_SIZE = 1024
)
Variables ¶
This section is empty.
Functions ¶
func EcdsaDecrypt ¶
func EcdsaDecrypt(privateKey *ecdsa.PrivateKey, ciphertext []byte) ([]byte, error)
使用私钥解密消息
func EcdsaEncrypt ¶
使用公钥加密消息
func EcdsaGenerateKey ¶
func EcdsaGenerateSignature ¶
func EcdsaVerifySignature ¶
func GenerateRandomAESKey ¶
GenerateRandomAESKey 生成随机AES密钥 keySize: 16(128-bit), 24(192-bit) 或 32(256-bit)
func GenerateRsaKeys ¶
Types ¶
type AES ¶
type AES interface {
AESEncrypt(plaintext []byte, key []byte, iv ...byte) (ciphertext []byte, err error)
AESDecrypt(ciphertext []byte, key []byte, iv ...byte) (plaintext []byte, err error)
AESEncryptHexString(plaintextHex string, keyHex string, ivHex string) (ciphertextHex string, err error)
AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
}
type CBC ¶
type CBC struct{}
CBC 实现 AES 接口
func (*CBC) AESDecrypt ¶
AESDecrypt AES-CBC 解密(二进制版)
func (*CBC) AESDecryptHexString ¶
func (c *CBC) AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
AESDecryptString AES-CBC 解密(字符串版)
func (*CBC) AESEncrypt ¶
AESEncrypt AES-CBC 加密(二进制版)
type CFB ¶
type CFB struct{}
CFB 实现 AES 接口
func (*CFB) AESDecrypt ¶
AESDecrypt AES-CFB 解密(二进制版)
func (*CFB) AESDecryptHexString ¶
func (c *CFB) AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
AESDecryptString AES-CFB 解密(字符串版)
func (*CFB) AESEncrypt ¶
AESEncrypt AES-CFB 加密(二进制版)
type GCM ¶
type GCM struct{}
GCM 实现 AES 接口
func (*GCM) AESDecrypt ¶
AESDecrypt AES-GCM 解密(二进制版)
func (*GCM) AESDecryptHexString ¶
func (g *GCM) AESDecryptHexString(ciphertextHex string, keyHex string, ivHex string) (plaintextHex string, err error)
AESDecryptString AES-GCM 解密(字符串版)
func (*GCM) AESEncrypt ¶
AESEncrypt AES-GCM 加密(二进制版)
Click to show internal directories.
Click to hide internal directories.