Documentation
¶
Index ¶
- Constants
- Variables
- func Digest(hash hash.Hash, src []byte) []byte
- func DigestString(hash hash.Hash, src string, base64Encoding bool) string
- func DigestX(hash hash.Hash, src []byte) []byte
- func DigestXString(hash hash.Hash, src string, base64Encoding bool) string
- func SM3Digest(src []byte) []byte
- func SM3Digest2(src []byte, iv string, gap int16) []byte
- func SM3DigestString(src string, base64Encoding bool) string
- func SM3DigestString2(src string, base64Encoding bool, iv string, gap int16) string
- type AES
- func NewAESInstance(key string) (*AES, error)
- func NewAESInstance2(key string, keyLength int) (*AES, error)
- func NewAESInstance3(key, iv string) (*AES, error)
- func NewAESInstance4(key, iv string, keyLength int) (*AES, error)
- func NewAESInstance5(key []byte, keyLength int) (*AES, error)
- func NewAESInstance6(key, iv []byte, keyLength int) (*AES, error)
- type DES
- func NewDESInstance(key string) (*DES, error)
- func NewDESInstance2(key, iv string) (*DES, error)
- func NewDESInstance3(key []byte) (*DES, error)
- func NewDESInstance4(key, iv []byte) (*DES, error)
- func NewTriDESInstance(key string) (*DES, error)
- func NewTriDESInstance2(key, iv string) (*DES, error)
- func NewTriDESInstance3(key []byte) (*DES, error)
- func NewTriDESInstance4(key, iv []byte) (*DES, error)
- func (d *DES) DESDecrypt(encrypted []byte) []byte
- func (d *DES) DESDecryptString(encrypted string, base64Encoding bool) (string, error)
- func (d *DES) DESEncrypt(src []byte) []byte
- func (d *DES) DESEncryptString(src string, base64Encoding bool) string
- func (d *DES) TriDESDecrypt(encrypted []byte) []byte
- func (d *DES) TriDESDecryptString(encrypted string, base64Encoding bool) (string, error)
- func (d *DES) TriDESEncrypt(src []byte) []byte
- func (d *DES) TriDESEncryptString(src string, base64Encoding bool) string
- type DSA
- func (d *DSA) GenKeyPair(paramSize dsa.ParameterSizes) error
- func (d *DSA) Sign(src []byte) (r, s *big.Int, err error)
- func (d *DSA) Sign2(src []byte, hash crypto.Hash) (r, s *big.Int, err error)
- func (d *DSA) SignString(src string, base64Encoding bool) (r, s string, err error)
- func (d *DSA) Verify(src []byte, r, s *big.Int) bool
- func (d *DSA) Verify2(src []byte, hash crypto.Hash, r, s *big.Int) bool
- func (d *DSA) VerifyString(src, r, s string, base64Encoding bool) (bool, error)
- type ECDSA
- func (e *ECDSA) GenKeyPair(c elliptic.Curve) error
- func (e *ECDSA) LoadKeyPair(pubKeyFile, priKeyFile string) error
- func (e *ECDSA) LoadPrivateKey(priKeyFile string) error
- func (e *ECDSA) LoadPublicKey(pubKeyFile string) error
- func (e *ECDSA) SaveKeyPair(pubKeyFile, priKeyFile string) error
- func (e *ECDSA) SavePrivateKey(priKeyFile string) error
- func (e *ECDSA) SavePublicKey(pubKeyFile string) error
- func (e *ECDSA) Sign(src []byte) (r, s *big.Int, err error)
- func (e *ECDSA) Sign2(src []byte, hash crypto.Hash) (r, s *big.Int, err error)
- func (e *ECDSA) SignString(src string, base64Encoding bool) (r, s string, err error)
- func (e *ECDSA) Verify(src []byte, r, s *big.Int) bool
- func (e *ECDSA) Verify2(src []byte, hash crypto.Hash, r, s *big.Int) bool
- func (e *ECDSA) VerifyString(src, r, s string, base64Encoding bool) (bool, error)
- type RC4
- func NewRC4Instance(key string) (*RC4, error)
- func NewRC4Instance2(key string, keyLength int) (*RC4, error)
- func NewRC4Instance3(key, iv string) (*RC4, error)
- func NewRC4Instance4(key, iv string, keyLength int) (*RC4, error)
- func NewRC4Instance5(key []byte, keyLength int) (*RC4, error)
- func NewRC4Instance6(key, iv []byte, keyLength int) (*RC4, error)
- type RSA
- func (r *RSA) Decrypt(encrypted []byte) ([]byte, error)
- func (r *RSA) DecryptString(encrypted string, base64Encoding bool) (string, error)
- func (r *RSA) Encrypt(src []byte) ([]byte, error)
- func (r *RSA) EncryptString(src string, base64Encoding bool) (string, error)
- func (r *RSA) GenKeyPair(keyLength int) error
- func (r *RSA) LoadKeyPair(pubKeyFile, priKeyFile string) error
- func (r *RSA) LoadPrivateKey(priKeyFile string) error
- func (r *RSA) LoadPublicKey(pubKeyFile string) error
- func (r *RSA) SaveKeyPair(pubKeyFile, priKeyFile string) error
- func (r *RSA) SavePrivateKey(priKeyFile string) error
- func (r *RSA) SavePublicKey(pubKeyFile string) error
- func (r *RSA) Sign(src []byte) ([]byte, error)
- func (r *RSA) Sign2(src []byte, hash crypto.Hash) ([]byte, error)
- func (r *RSA) SignString(src string, base64Encoding bool) (string, error)
- func (r *RSA) Verify(src, sign []byte) error
- func (r *RSA) Verify2(src, sign []byte, hash crypto.Hash) error
- func (r *RSA) VerifyString(src, sign string, base64Encoding bool) error
- type SM3
Constants ¶
const ( KEY_LENGTH = 8 KEY_LENGTH_24 = KEY_LENGTH * 3 KEY_LENGTH_128 = KEY_LENGTH * 16 KEY_LENGTH_192 = KEY_LENGTH * 24 KEY_LENGTH_256 = KEY_LENGTH * 32 KEY_LENGTH_1024 = KEY_LENGTH * 128 KEY_LENGTH_2048 = KEY_LENGTH * 256 )
const ( LENGTH_IV = 32 LENGTH_TJ = 64 LENGTH_BYTES_OF_INT = 4 LENGTH_DIGEST = 32 LENGTH_BLOCK = 64 TJ_START = 0xA748B290 DEFAULT_IV = "a12BC!@&def568%$Gh9#ijKlmNoPqr43" DEFAULT_GAP = 256 )
Variables ¶
Functions ¶
func Digest ¶
message digest, with given hash algorithm. hash should be MD5,SHA1,SHA256,SHA512,CHINA_SM3, which is defined in current file src is the bytes to be digested
func DigestString ¶
message digest, with given hash algorithm. hash should be MD5,SHA1,SHA256,SHA512,CHINA_SM3, which is defined in current file src is the string to be digested if base64Encoding is true, result string will be encoded with base64, else will be encoded with hex
func DigestX ¶
message digest, with given hash algorith. after digested, src will be added to result. hash should be MD5,SHA1,SHA256,SHA512,CHINA_SM3, which is defined in current file src is the bytes to be digested
func DigestXString ¶
message digest, with given hash algorithm. after digested, src will be added to result. hash should be MD5,SHA1,SHA256,SHA512,CHINA_SM3, which is defined in current file src is the string to be digested if base64Encoding is true, result string will be encoded with base64, else will be encoded with hex
func SM3DigestString ¶
Types ¶
type AES ¶
type AES struct {
// contains filtered or unexported fields
}
func NewAESInstance ¶
create aes instance, use given key string. in this method, key length is set to 128bit, and iv equals to key
func NewAESInstance2 ¶
create aes instance with given key string & key length. key length should be 128, 256, 512 etc. in this method, iv equals to key
func NewAESInstance3 ¶
create aes instance with given key & iv string. in this method, key length is set to 128bit
func NewAESInstance4 ¶
create aes instance with given key & iv string & key length.
func NewAESInstance5 ¶
create aes instance with given key bytes & key length. in this method, iv equals to key
func NewAESInstance6 ¶
create aes instance with given key/iv bytes & key length.
func (*AES) DecryptString ¶
decrypt encrypted string. encrypted should be encrypted in CBC mode if base64Encoding is true, means the encrypted string is encoded with base64, else is encoded with hex
type DES ¶
type DES struct {
// contains filtered or unexported fields
}
func NewDESInstance ¶
func NewDESInstance2 ¶
func NewDESInstance3 ¶
func NewDESInstance4 ¶
func NewTriDESInstance ¶
func NewTriDESInstance2 ¶
func NewTriDESInstance3 ¶
func NewTriDESInstance4 ¶
func (*DES) DESDecrypt ¶
func (*DES) DESDecryptString ¶
func (*DES) DESEncrypt ¶
func (*DES) DESEncryptString ¶
func (*DES) TriDESDecrypt ¶
func (*DES) TriDESDecryptString ¶
func (*DES) TriDESEncrypt ¶
type DSA ¶
type DSA struct {
// contains filtered or unexported fields
}
func NewDSAInstance ¶
func NewDSAInstance() *DSA
func (*DSA) GenKeyPair ¶
func (d *DSA) GenKeyPair(paramSize dsa.ParameterSizes) error
func (*DSA) SignString ¶
type ECDSA ¶
type ECDSA struct {
// contains filtered or unexported fields
}
func NewECDSAInstance ¶
func NewECDSAInstance() *ECDSA
func (*ECDSA) LoadKeyPair ¶
func (*ECDSA) LoadPrivateKey ¶
func (*ECDSA) LoadPublicKey ¶
func (*ECDSA) SaveKeyPair ¶
func (*ECDSA) SavePrivateKey ¶
func (*ECDSA) SavePublicKey ¶
func (*ECDSA) SignString ¶
type RC4 ¶
type RC4 struct {
// contains filtered or unexported fields
}
func NewRC4Instance ¶
func NewRC4Instance3 ¶
func (*RC4) DecryptString ¶
type RSA ¶
type RSA struct {
// contains filtered or unexported fields
}
func NewRSAInstance ¶
func NewRSAInstance() *RSA