Documentation ¶
Overview ¶
Package gocrypto is a simple encryption and decryption package
Index ¶
- Constants
- func DecodeString(data string, encodedType Encode) (keyDecoded []byte, err error)
- func EncodeToString(data []byte, encodeType Encode) (string, 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(src []byte, blockSize int) []byte
- func ParsePrivateKey(privateKeyDecoded []byte, keyType Secret) (*rsa.PrivateKey, error)
- func UnPaddingPKCS7(src []byte, blockSize int) []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 Hash
- type Padding
- 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 types
func GetHashFunc ¶
GetHashFunc gets the crypto hash func & type in different hash types
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 ¶
CipherCrypt is a simple encryption and decryption package
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
Directories ¶
Path | Synopsis |
---|---|
Package aes implements the AES encryption algorithm.
|
Package aes implements the AES encryption algorithm. |
Package des implements the DES encryption algorithm.
|
Package des implements the DES encryption algorithm. |
Package hash for crypto Hash
|
Package hash for crypto Hash |
Package rsa provides RSA encryption and decryption, signature and verification functions.
|
Package rsa provides RSA encryption and decryption, signature and verification functions. |