Documentation ¶
Index ¶
- Constants
- func AESCBCDecrypt(c, k []byte) ([]byte, error)
- func AESCBCEncrypt(s, k []byte) ([]byte, error)
- func AESCFBDecrypt(c, k []byte) ([]byte, error)
- func AESCFBEncrypt(s, k []byte) ([]byte, error)
- func AESGCMDecrypt(c, k, n []byte) ([]byte, error)
- func AESGCMEncrypt(s, k, n []byte) ([]byte, error)
- func AESMake256Key(k []byte) []byte
- func CheckHmacSha1(message, messageMAC, key []byte) (bool, error)
- func CheckHmacSha256(message, messageMAC, key []byte) (bool, error)
- func GBK2UTF8(s []byte) ([]byte, error)
- func HkdfSha1RandomSalt(secret, info []byte, sl int) (key []byte, salt []byte, err error)
- func HkdfSha1WithSalt(secret, salt, info []byte) (key []byte, err error)
- func HkdfSha256RandomSalt(secret, info []byte, sl int) (key []byte, salt []byte, err error)
- func HkdfSha256WithSalt(secret, salt, info []byte) (key []byte, err error)
- func HmacSha1(message, key []byte) ([]byte, error)
- func HmacSha256(message, key []byte) ([]byte, error)
- func MD5(s string) (r string)
- func PKCSPadding(c []byte, blockSize int) []byte
- func PKCSUnPadding(s []byte) ([]byte, error)
- func RSASignWithSHA256(data []byte, key []byte) ([]byte, error)
- func RSASignWithSHA256PKCS1(data []byte, key []byte) ([]byte, error)
- func RSAVerifyWithSHA256(data, sign, key []byte) error
- func SHA1(s string) (r string)
- func SHA256(s string) (r string)
- func SHA256Bytes(s []byte) ([]byte, error)
- func URIEscape(s string) string
- func URIUnescape(s string) (string, error)
- func UTF82GBK(s []byte) ([]byte, error)
- type KV
Constants ¶
const AES256KeyLength = 32
AES256KeyLength is the length of key for AES 256 crypt
Variables ¶
This section is empty.
Functions ¶
func AESCBCDecrypt ¶
AESCBCDecrypt decrypt c with given k k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits First 16 bytes of cipher data is the IV.
func AESCBCEncrypt ¶
AESCBCEncrypt encrypt s with given k k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits First 16 bytes of cipher data is the IV.
func AESCFBDecrypt ¶
AESDecrypt decrypt c with given k k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits First 16 bytes of cipher data is the IV.
func AESCFBEncrypt ¶
AESCFBEncrypt encrypt s with given k. k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits. First 16 bytes of cipher data is the IV.
func AESGCMDecrypt ¶
AESGCMDecrypt decrypt s use k and nonce
func AESGCMEncrypt ¶
AESGCMEncrypt encrypt s use k and nonce
func AESMake256Key ¶
AESMake256Key cut or append empty data on the key and make sure the key lenth equal 32
func CheckHmacSha1 ¶
func CheckHmacSha256 ¶
func HkdfSha1RandomSalt ¶
func HkdfSha1WithSalt ¶
func HkdfSha256RandomSalt ¶
func HkdfSha256WithSalt ¶
func HmacSha256 ¶
func PKCSPadding ¶
PKCS#5 padding is identical to PKCS#7 padding, except that it has only been defined for block ciphers that use a 64-bit (8-byte) block size. In practice the two can be used interchangeably. Common blockSize is aes.BlockSize.
func PKCSUnPadding ¶
func RSASignWithSHA256 ¶
key is private key, PKCS#8.
func RSASignWithSHA256PKCS1 ¶
key is private key, PKCS#1.
func RSAVerifyWithSHA256 ¶
key is public key, nil means passed.
func SHA256Bytes ¶
SHA256 encrypt s according to sha256 algorithm
func URIUnescape ¶
Types ¶
type KV ¶
type KV struct {
AESKey []byte
}
KV can be used to crypt value by key and give it a lifecycle (s). Can be used in cookies
func (*KV) DecryptStruct ¶
Decrypt key, value, lifecycle is second, 0 is no expired time.