Documentation ¶
Index ¶
- func AESCBCDecrypt(c, key []byte) ([]byte, error)
- func AESCBCEncrypt(p, key []byte) ([]byte, error)
- func Base64AESCBCDecrypt(c string, key []byte) ([]byte, error)
- func Base64AESCBCEncrypt(p, key []byte) (string, error)
- func Base64DESCBCDecrypt(c string, key []byte) ([]byte, error)
- func Base64DESCBCEncrypt(p, key []byte) (string, error)
- func Base64TriDESCBCDecrypt(c string, key []byte) ([]byte, error)
- func Base64TriDESCBCEncrypt(p, key []byte) (string, error)
- func DESCBCDecrypt(c, key []byte) ([]byte, error)
- func DESCBCEncrypt(p, key []byte) ([]byte, error)
- func GenRsaKey(bits int) (prvkey, pubkey []byte, err error)
- func HMAC(str, key string, hashName string, capital bool) string
- func HMACMD5(str, key string) string
- func HMACMd5(str, key string) string
- func HMACSHA1(str, key string) string
- func HMACSHA224(str, key string) string
- func HMACSHA256(str, key string) string
- func HMACSHA384(str, key string) string
- func HMACSHA512(str, key string) string
- func HMACSha1(str, key string) string
- func HMACSha224(str, key string) string
- func HMACSha256(str, key string) string
- func HMACSha384(str, key string) string
- func HMACSha512(str, key string) string
- func Hash(s string, name string, capital bool) string
- func MD5(s string) string
- func Md5(s string) string
- func PKCS7Padding(p []byte, blockSize int) []byte
- func PKCS7UnPadding(p []byte) ([]byte, error)
- func RsaDecrypt(prvkey, cipher []byte) ([]byte, error)
- func RsaEncrypt(pubkey, data []byte) ([]byte, error)
- func RsaSign(prvkey []byte, hash crypto.Hash, data []byte) ([]byte, error)
- func RsaVerifySign(pubkey []byte, hash crypto.Hash, data, sig []byte) error
- func SHA1(s string) string
- func SHA224(s string) string
- func SHA256(s string) string
- func SHA384(s string) string
- func SHA512(s string) string
- func Sha1(s string) string
- func Sha224(s string) string
- func Sha256(s string) string
- func Sha384(s string) string
- func Sha512(s string) string
- func TriDESCBCDecrypt(src, key []byte) ([]byte, error)
- func TriDESCBCEncrypt(src, key []byte) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESCBCDecrypt ¶
AESCBCDecrypt decrypts cipher text with AES algorithm in CBC mode. Note that key length must be 16, 24 or 32 bytes to select AES-128, AES-192, or AES-256.
func AESCBCEncrypt ¶
AESCBCEncrypt encrypts data with AES algorithm in CBC mode. Note that key length must be 16, 24 or 32 bytes to select AES-128, AES-192, or AES-256.
func Base64AESCBCDecrypt ¶
Base64AESCBCDecrypt decrypts cipher text encoded by base64 with AES algorithm in CBC mode.
func Base64AESCBCEncrypt ¶
Base64AESCBCEncrypt encrypts data with AES algorithm in CBC mode and then encode using base64.
func Base64DESCBCDecrypt ¶
Base64DESCBCDecrypt decrypts cipher text encoded by base64 with DES algorithm in CBC mode.
func Base64DESCBCEncrypt ¶
Base64DESCBCEncrypt encrypts data with DES algorithm in CBC mode and encoded by base64.
func Base64TriDESCBCDecrypt ¶
Base64TriDESCBCDecrypt decrypts cipher text encoded by base64 with 3DES algorithm in CBC mode.
func Base64TriDESCBCEncrypt ¶
Base64TriDESCBCEncrypt encrypts data with 3DES algorithm in CBC mode and encoded by base64.
func DESCBCDecrypt ¶
DESCBCDecrypt decrypts cipher text with DES algorithm in CBC mode. Note that key length must be 8 bytes.
func DESCBCEncrypt ¶
DESCBCEncrypt encrypts data with DES algorithm in CBC mode. Note that key length must be 8 bytes.
func HMAC ¶
HMAC generates authentication code based on specified hash algorithm. e.g. HMAC("", "", "MD5", false) returns 74e6f7298a9c2d168935f58c001bad88.
func HMACMD5 ¶
HMACMD5 generates 32 uppercase hexadecimal characters authentication code based on MD5.
func HMACMd5 ¶
HMACMd5 generates 32 lowercase hexadecimal characters authentication code based on MD5.
func HMACSHA1 ¶
HMACSHA1 generates 40 uppercase hexadecimal characters authentication code based on SHA1.
func HMACSHA224 ¶
HMACSHA224 generates 56 uppercase hexadecimal characters authentication code based on SHA224.
func HMACSHA256 ¶
HMACSHA256 generates 64 uppercase hexadecimal characters authentication code based on SHA256.
func HMACSHA384 ¶
HMACSHA384 generates 96 uppercase hexadecimal characters authentication code based on SHA384.
func HMACSHA512 ¶
HMACSHA512 generates 128 uppercase hexadecimal characters authentication code based on SHA512.
func HMACSha1 ¶
HMACSha1 generates 40 lowercase hexadecimal characters authentication code based on SHA1.
func HMACSha224 ¶
HMACSha224 generates 56 lowercase hexadecimal characters authentication code based on SHA224.
func HMACSha256 ¶
HMACSha256 generates 64 lowercase hexadecimal characters authentication code based on SHA256.
func HMACSha384 ¶
HMACSha384 generates 96 lowercase hexadecimal characters authentication code based on SHA384.
func HMACSha512 ¶
HMACSha512 generates 128 lowercase hexadecimal characters authentication code based on SHA512.
func Hash ¶
Hash generates a checksum of the specified hash algorithm. E.g. Hash("", "MD5", false) returns d41d8cd98f00b204e9800998ecf8427e.
func PKCS7Padding ¶
PKCS7Padding fills plaintext as an integral multiple of the block length. In cryptography, PKCS stands for "Public Key Cryptography Standards". These are a group of public key cryptography standards devised and published by RSA Security LLC, starting in the early 1990s. PKCS#7 is Cryptographic Message Syntax Standard used to sign and/or encrypt messages under a PKI. More information about PKCS#7 please refer to the RFC 2315. The PKCS#7 padding method works by adding bytes that all have the same value as the number of bytes added to the plaintext. For example, if the last block of plaintext is 3 bytes long and the block size is 8 bytes, then 5 bytes of padding are added to make the total length of the plaintext 8 bytes. The value of the 5 bytes will be the hex value 0x05, since 5 bytes were added as padding.
func PKCS7UnPadding ¶
PKCS7UnPadding removes padding data from the tail of plaintext.
func RsaDecrypt ¶
RsaDecrypt decrypts data using rsa private key.
func RsaEncrypt ¶
RsaEncrypt encrypts data using rsa public key.
func RsaVerifySign ¶
RsaVerifySign verifies signature using public key in PEM format. A valid signature is indicated by returning a nil error.
func TriDESCBCDecrypt ¶
TriDESCBCDecrypt decrypts cipher text with 3DES algorithm in CBC mode. Note that key length must be 24 bytes
func TriDESCBCEncrypt ¶
TriDESCBCEncrypt encrypts data with 3DES algorithm in CBC mode. Note that key length must be 24 bytes
Types ¶
This section is empty.