Documentation
¶
Index ¶
- Constants
- Variables
- func AesCBCDecrypt(src, key, iv []byte, padding string) ([]byte, error)
- func AesCBCEncrypt(src, key, iv []byte, padding string) ([]byte, error)
- func AesECBDecrypt(src, key []byte, padding string) ([]byte, error)
- func AesECBEncrypt(src, key []byte, padding string) ([]byte, error)
- func AesNewCipher(key []byte) (cipher.Block, error)
- func CBCDecrypt(block cipher.Block, src, iv []byte, padding string) ([]byte, error)
- func CBCEncrypt(block cipher.Block, src, iv []byte, padding string) ([]byte, error)
- func Des3CBCDecrypt(src, key, iv []byte, padding string) ([]byte, error)
- func Des3CBCEncrypt(src, key, iv []byte, padding string) ([]byte, error)
- func Des3ECBDecrypt(src, key []byte, padding string) ([]byte, error)
- func Des3ECBEncrypt(src, key []byte, padding string) ([]byte, error)
- func DesCBCDecrypt(src, key, iv []byte, padding string) ([]byte, error)
- func DesCBCEncrypt(src, key, iv []byte, padding string) ([]byte, error)
- func DesECBDecrypt(src, key []byte, padding string) ([]byte, error)
- func DesECBEncrypt(src, key []byte, padding string) ([]byte, error)
- func DesNewCipher(key []byte) (cipher.Block, error)
- func ECBDecrypt(block cipher.Block, src []byte, padding string) ([]byte, error)
- func ECBEncrypt(block cipher.Block, src []byte, padding string) ([]byte, error)
- func HmacSha1(key string, data string) []byte
- func HmacSha1ToString(key string, data string) string
- func HmacSha256(key string, data string) []byte
- func HmacSha256ToString(key string, data string) string
- func KeyGenerator(src []byte, blockSize int) []byte
- func Md5(str string) []byte
- func Md5ToString(str string) string
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func PKCS5Padding(src []byte, blockSize int) []byte
- func PKCS5Unpadding(src []byte) ([]byte, error)
- func PKCS7Padding(src []byte, blockSize int) []byte
- func PKCS7UnPadding(src []byte) ([]byte, error)
- func Padding(padding string, src []byte, blockSize int) []byte
- func RSADecrypt(src, priKey []byte) ([]byte, error)
- func RSAEncrypt(src, pubKey []byte) ([]byte, error)
- func RSAGenerateKey(bits int, out io.Writer) error
- func RSAGeneratePublicKey(priKey []byte, out io.Writer) error
- func RSASign(src []byte, priKey []byte, hash crypto.Hash) ([]byte, error)
- func RSAVerify(src, sign, pubKey []byte, hash crypto.Hash) error
- func SHA1(data []byte) []byte
- func Sha1(str string) []byte
- func Sha256(str string) []byte
- func UnPadding(padding string, src []byte) ([]byte, error)
- func ZerosPadding(src []byte, blockSize int) []byte
- func ZerosUnPadding(src []byte) ([]byte, error)
Constants ¶
const PKCS5_PADDING = "PKCS5"
const PKCS7_PADDING = "PKCS7"
const ZEROS_PADDING = "ZEROS"
Variables ¶
var ErrUnPadding = errors.New("UnPadding error")
Error indicating an issue during the unpadding process.
Functions ¶
func AesCBCDecrypt ¶
AesCBCDecrypt decrypts data using the CBC mode of the AES algorithm.
func AesCBCEncrypt ¶
AesCBCEncrypt encrypts data using the CBC mode of the AES algorithm.
func AesECBDecrypt ¶
AesECBDecrypt decrypts data using the ECB mode of the AES algorithm.
func AesECBEncrypt ¶
AesECBEncrypt encrypts data using the ECB mode of the AES algorithm.
func AesNewCipher ¶ added in v1.6.0
AesNewCipher creates and returns a new AES cipher block. Automatically pads the key length.
func CBCDecrypt ¶
CBCDecrypt decrypts data using the CBC (Cipher Block Chaining) mode.
func CBCEncrypt ¶
CBCEncrypt encrypts data using the CBC (Cipher Block Chaining) mode.
func Des3CBCDecrypt ¶
Des3CBCDecrypt decrypts data using the CBC mode of the 3DES algorithm.
func Des3CBCEncrypt ¶
Des3CBCEncrypt encrypts data using the CBC mode of the 3DES algorithm.
func Des3ECBDecrypt ¶
Des3ECBDecrypt decrypts data using the ECB mode of the 3DES algorithm.
func Des3ECBEncrypt ¶
Des3ECBEncrypt encrypts data using the ECB mode of the 3DES algorithm.
func DesCBCDecrypt ¶
DesCBCDecrypt decrypts data using the CBC mode of the DES algorithm.
func DesCBCEncrypt ¶
DesCBCEncrypt encrypts data using the CBC mode of the DES algorithm.
func DesECBDecrypt ¶
DesECBDecrypt decrypts data using the ECB mode of the DES algorithm.
func DesECBEncrypt ¶
DesECBEncrypt encrypts data using the ECB mode of the DES algorithm.
func DesNewCipher ¶ added in v1.6.0
DesNewCipher creates and returns a new DES cipher block, adjusting the key length if necessary.
func ECBDecrypt ¶
Decrypts data using the ECB (Electronic Codebook) mode.
func ECBEncrypt ¶
Encrypts data using the ECB (Electronic Codebook) mode.
func HmacSha1ToString ¶ added in v1.5.0
HmacSha1ToString Calculate the sha1 hash of a string using the HMAC method, outputs lowercase hexits
func HmacSha256 ¶ added in v1.5.0
HmacSha256 Calculate the sha256 hash of a string using the HMAC method
func HmacSha256ToString ¶ added in v1.5.0
HmacSha256ToString Calculate the sha256 hash of a string using the HMAC method, outputs lowercase hexits
func KeyGenerator ¶
Generates a key based on the input data and specified block size.
func Md5ToString ¶ added in v1.3.0
Calculates the MD5 hash of a given string and returns the result as a hexadecimal string.
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func NewECBEncrypter ¶
NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func PKCS5Padding ¶
Applies PKCS5 padding to the input data. In practice, it uses PKCS7 padding.
func PKCS5Unpadding ¶
Removes PKCS5 padding from the input data. In practice, it uses PKCS7 unpadding.
func PKCS7Padding ¶
Applies PKCS7 padding to the input data.
func PKCS7UnPadding ¶
Removes PKCS7 padding from the input data.
func RSADecrypt ¶ added in v1.2.0
Decrypts data using RSA.
func RSAEncrypt ¶ added in v1.2.0
Encrypts data using RSA.
func RSAGenerateKey ¶ added in v1.2.0
Generates a new RSA private key.
func RSAGeneratePublicKey ¶ added in v1.2.0
Generates an RSA public key from a private key.
func ZerosPadding ¶
Applies zero padding to the input data.
func ZerosUnPadding ¶
Removes zero padding from the input data.
Types ¶
This section is empty.