Documentation ¶
Index ¶
- Constants
- func DecodeString(data string, encodedType Encode) ([]byte, error)
- func EncodeToString(data []byte, encodeType Encode) (string, error)
- func GenRsaKey(bits int) ([]byte, []byte, error)
- func GetHash(data []byte, hashType Hash) (h crypto.Hash, hashed []byte, err error)
- func GetHashFunc(hashType Hash) (f func() hash.Hash, h crypto.Hash)
- func PKCS7Padding(cipherText []byte, blockSize int) []byte
- func ParsePrivateKey(privateKeyDecoded []byte, keyType Secret) (*rsa.PrivateKey, error)
- func UnPaddingPKCS7(src []byte) []byte
- type Cipher
- type CipherCrypt
- func (cc *CipherCrypt) Decrypt(src []byte, c Cipher, ivs ...[]byte) (dst []byte, err error)
- func (cc *CipherCrypt) DecryptToString(encodeType Encode, src []byte, c Cipher, ivs ...[]byte) (dst string, err error)
- func (cc *CipherCrypt) Encrypt(src []byte, c Cipher, ivs ...[]byte) (dst []byte, err error)
- func (cc *CipherCrypt) EncryptToString(encodeType Encode, src []byte, c Cipher, ivs ...[]byte) (dst string, err error)
- type Crypt
- type Encode
- type EnvEncrypt
- type Hash
- type Option
- type Padding
- type RSASecret
- type RsaCrypt
- type Secret
Constants ¶
const ( PaddingPKCS5 = iota PaddingPKCS7 )
const ( ECB = iota CBC CFB OFB )
Variables ¶
This section is empty.
Functions ¶
func DecodeString ¶
DecodeString decodes string data to bytes in designed encoded type
func EncodeToString ¶
EncodeToString encodes data to string with encode type
func GetHashFunc ¶
GetHashFunc gets the crypto hash func & type in different hash type
func PKCS7Padding ¶
PKCS7Padding adds padding data using pkcs7 rules , adapt to PKCS5 &PKCS7
func ParsePrivateKey ¶
func ParsePrivateKey(privateKeyDecoded []byte, keyType Secret) (*rsa.PrivateKey, error)
ParsePrivateKey parses private key bytes to rsa privateKey
func UnPaddingPKCS7 ¶
UnPaddingPKCS7 un-padding src data to original data , adapt to PKCS5 &PKCS7
Types ¶
type CipherCrypt ¶
func (*CipherCrypt) Decrypt ¶
Decrypt decrypts src to dst with cipher & iv, if failed return error src the original encrypted bytes c the defined cipher type,now support CBC,CFB,OFB,ECB ivs the iv for CBC,CFB,OFB mode dst the decrypted bytes
func (*CipherCrypt) DecryptToString ¶
func (cc *CipherCrypt) DecryptToString(encodeType Encode, src []byte, c Cipher, ivs ...[]byte) (dst string, err error)
DecryptToString decrypts src then encodes return data to string encodeType now support String,HEX,Base64
func (*CipherCrypt) Encrypt ¶
Encrypt encrypts src to dst with cipher & iv, if failed return error src the original source bytes c the defined cipher type,now support CBC,CFB,OFB,ECB ivs the iv for CBC,CFB,OFB mode dst the encrypted bytes
func (*CipherCrypt) EncryptToString ¶
func (cc *CipherCrypt) EncryptToString(encodeType Encode, src []byte, c Cipher, ivs ...[]byte) (dst string, err error)
EncryptToString encrypts src then encodes data returned to string encodeType now support String,HEX,Base64
type EnvEncrypt ¶
type EnvEncrypt struct {
// contains filtered or unexported fields
}
Encrypt encrypt 实例对象封装
func (*EnvEncrypt) DecryptAddonConfigMap ¶
func (e *EnvEncrypt) DecryptAddonConfigMap(configMap *map[string]interface{}) error
encryptConfigMap 解密环境变量中password信息
func (*EnvEncrypt) DecryptPassword ¶
func (e *EnvEncrypt) DecryptPassword(src string) (string, error)
encryptConfigMap 解密
func (*EnvEncrypt) EncryptPassword ¶
func (e *EnvEncrypt) EncryptPassword(src string) (string, error)
encryptConfigMap 加密
type RsaCrypt ¶
type RsaCrypt struct {
// contains filtered or unexported fields
}
func NewRSAScrypt ¶
NewRSACrypt init with the RSA secret info