Documentation
¶
Index ¶
- func AesCtrCrypt(plainText []byte, key []byte) ([]byte, error)
- func AesDecryptCBC(cryted []byte, key []byte) ([]byte, error)
- func AesDecryptCFB(encrypted []byte, key []byte) ([]byte, error)
- func AesDecryptECB(encrypted []byte, key []byte) ([]byte, error)
- func AesDecryptOFB(data []byte, key []byte) ([]byte, error)
- func AesEncryptCBC(orig []byte, key []byte) ([]byte, error)
- func AesEncryptCFB(origData []byte, key []byte) ([]byte, error)
- func AesEncryptECB(src []byte, key []byte) ([]byte, error)
- func AesEncryptOFB(data []byte, key []byte) ([]byte, error)
- func GeneratePassword(original string, salt string) string
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) ([]byte, error)
- func PrivateBytesToPEM(buf []byte) []byte
- func PrivateKeyAsPEM(key *rsa.PrivateKey) []byte
- func PublicBytesToPEM(buf []byte) []byte
- func PublicKeyAsPEM(key *rsa.PublicKey) []byte
- func RsaDecrypt(ciphertext, privateKey []byte) ([]byte, error)
- func RsaDecryptOAEP(msg []byte, priv *rsa.PrivateKey) ([]byte, error)
- func RsaEncrypt(origData, publicKey []byte) ([]byte, error)
- func RsaEncryptOAEP(msg []byte, pub *rsa.PublicKey) ([]byte, error)
- type ECDH
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesCtrCrypt ¶
AesCtrCrypt 加密、解密使用同一个函数
func GeneratePassword ¶
func PKCS7Padding ¶
PKCS7Padding 补码 AES加密数据块分组长度必须为128bit(byte[16]),密钥长度可以是128bit(byte[16])、192bit(byte[24])、256bit(byte[32])中的任意一个。
func PrivateBytesToPEM ¶
func PrivateKeyAsPEM ¶
func PrivateKeyAsPEM(key *rsa.PrivateKey) []byte
PrivateKeyAsPEM takes a pointer to an RSA private key and returns its PEM encoding as a byte slice.
func PublicBytesToPEM ¶
func PublicKeyAsPEM ¶
PublicKeyAsPEM takes a pointer to an RSA private key and returns its corresponding public key's PEM encoding as a byte slice.
func RsaDecrypt ¶
func RsaDecryptOAEP ¶
func RsaDecryptOAEP(msg []byte, priv *rsa.PrivateKey) ([]byte, error)
RsaDecryptOAEP takes a message as a byte slice and an RSA private key, and returns the decrypted message as a byte slice.
func RsaEncrypt ¶
Types ¶
type ECDH ¶
type ECDH interface {
// GenerateKey 生成公私钥对
GenerateKey() error
// MarshalPublicKey 将公钥转换为字节
MarshalPublicKey() []byte
// MarshalPrivateKey 将私钥转换为字节
MarshalPrivateKey() []byte
GenerateSharedSecret([]byte) ([]byte, []byte, error)
}
ECDH The main interface for ECDH key exchange.
func NewCurveKey ¶
func NewCurveKey() ECDH
Click to show internal directories.
Click to hide internal directories.