crypto

package
v0.0.0-...-533a6ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PaddingPkcs5    = "pkcs5"    // 填充方式:pkcs5(块大小为8bytes的pkcs7填充)
	PaddingPkcs7    = "pkcs7"    // 填充方式:pkcs7
	PaddingZero     = "zero"     // 填充方式:0填充
	PaddingAnsix923 = "ansix923" // 填充方式:ansix923(除最后一个字节外全部填充0的pkcs7填充)
	PaddingIso10126 = "iso10126" // 填充方式:iso10126(除最后一个字节外全部填充随机数的pkcs7填充)
)

Variables

This section is empty.

Functions

func AesCbcDecrypt

func AesCbcDecrypt(key, iv, ciphertext []byte, padding string) (plaintext []byte, err error)

AesCbcDecrypt cbc模式的aes解密 @param key 密钥 @param iv 初始偏移向量 @param ciphertext 密文 @param padding 填充方式

func AesCbcEncrypt

func AesCbcEncrypt(key, iv, plaintext []byte, padding string) (ciphertext []byte, err error)

AesCbcEncrypt cbc模式的aes加密 @param key 密钥 @param iv 初始偏移向量 @param plaintext 明文 @param padding 填充方式

func CreateSm2PrivateKeyWithBase64

func CreateSm2PrivateKeyWithBase64(privateKey string) (*sm2.PrivateKey, error)

CreateSm2PrivateKeyWithBase64 通过base64编码字符串构造sm2私钥

func CreateSm2PublicKeyWithBase64

func CreateSm2PublicKeyWithBase64(publicKey string) (*sm2.PublicKey, error)

CreateSm2PublicKeyWithBase64 通过base64编码字符串构造sm2公钥

func EcbDecrypt

func EcbDecrypt(block cipher.Block, ciphertext []byte) ([]byte, error)

EcbDecrypt ecb模式解密

func EcbEncrypt

func EcbEncrypt(block cipher.Block, plaintext []byte) ([]byte, error)

EcbEncrypt ecb模式加密

func Padding

func Padding(padding string, src []byte, blockSize int) []byte

Padding 填充 @param padding 填充方式 @param src 原文 @param blockSize 块大小

func Sm2Decrypt

func Sm2Decrypt(privateKey *sm2.PrivateKey, ciphertext []byte, mode int) ([]byte, error)

Sm2Decrypt sm2解密 @param privateKey 私钥 @param ciphertext 密文 @param mode 密文顺序,参考github.com/tjfoc/gmsm/sm2包的枚举值,0为C1C3C2,1为C1C2C3

func Sm2Encrypt

func Sm2Encrypt(publicKey *sm2.PublicKey, plaintext []byte, mode int) ([]byte, error)

Sm2Encrypt sm2加密 @param publicKey 公钥 @param plaintext 明文内容 @param mode 密文顺序,参考github.com/tjfoc/gmsm/sm2包的枚举值,0为C1C3C2,1为C1C2C3

func Sm4CbcDecrypt

func Sm4CbcDecrypt(key, iv, ciphertext []byte, padding string) (plaintext []byte, err error)

Sm4CbcDecrypt cbc模式的sm4解密 @param key 密钥 @param iv 初始向量 @param ciphertext 密文 @param padding 填充方式

func Sm4CbcEncrypt

func Sm4CbcEncrypt(key, iv, plaintext []byte, padding string) (ciphertext []byte, err error)

Sm4CbcEncrypt cbc模式的sm4加密 @param key 密钥 @param iv 初始向量 @param plaintext 明文内容 @param padding 填充方式

func TripleDesEcbDecrypt

func TripleDesEcbDecrypt(key, ciphertext []byte, padding string) ([]byte, error)

TripleDesEcbDecrypt ecb模式的3des解密 @param key 加密key @param ciphertext 密文 @param padding 填充模式

func TripleDesEcbEncrypt

func TripleDesEcbEncrypt(key, plaintext []byte, padding string) ([]byte, error)

TripleDesEcbEncrypt ecb模式的3des加密 @param key 加密key @param plaintext 明文 @param padding 填充模式

func UnPadding

func UnPadding(padding string, src []byte) []byte

UnPadding 去填充 @param src 原文 @param padding 填充方式

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL