cryptoUtils

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputSize  = errors.New("input size too large")
	ErrEncryption = errors.New("encryption error")
)

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte, iv []byte) ([]byte, error)

func AesDecryptECB

func AesDecryptECB(data, key []byte) []byte

func AesDecryptECBPK5 added in v0.0.7

func AesDecryptECBPK5(data, key []byte) []byte

func AesDecryptECBPK7

func AesDecryptECBPK7(data, key []byte) []byte

func AesDecryptPKCS5

func AesDecryptPKCS5(crypted, key []byte, iv []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(origData, key []byte, iv []byte) ([]byte, error)

func AesEncryptECB

func AesEncryptECB(data, key []byte) (encrypted []byte)

func AesEncryptECBPK5 added in v0.0.7

func AesEncryptECBPK5(data, key []byte) (encrypted []byte)

func AesEncryptECBPK7

func AesEncryptECBPK7(data, key []byte) (encrypted []byte)

func AesEncryptPKCS5

func AesEncryptPKCS5(origData, key []byte, iv []byte) ([]byte, error)

func CompressBrotli added in v0.0.5

func CompressBrotli(data []byte) ([]byte, error)

CompressBrotli 压缩数据使用 Brotli 算法

func Crc32

func Crc32(s string) uint32

func DecompressBrotli added in v0.0.5

func DecompressBrotli(compressedData []byte) ([]byte, error)

DecompressBrotli 解压缩使用 Brotli 算法压缩的数据

func GenRsaKey

func GenRsaKey(filePath string) error

func Gzip

func Gzip(data []byte) []byte

func HmacSHA1

func HmacSHA1(data, key string) []byte

func HmacSHA256

func HmacSHA256(data, key []byte) string

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

使用PKCS7进行填充,IOS也是7

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

func RsaDecWithPriKey

func RsaDecWithPriKey(cipherByte []byte, privateKey string) ([]byte, error)

*

	@param cipherByte 密文
	@param privateKey 私钥字符串
  	私钥解密,返回原文

func RsaEncWithPKCS8

func RsaEncWithPKCS8(cipherText []byte, privateKey []byte) ([]byte, error)

* @param cipherText 待签名字段 RSA私钥签名sha1

func RsaEncWithPriKey

func RsaEncWithPriKey(priv *rsa.PrivateKey, data []byte) (enc []byte, err error)

func RsaEncWithPubKey

func RsaEncWithPubKey(sourceBytes, pubKey []byte) ([]byte, error)

*

@param sourceBytes 原文
@param publicKey  公钥字符串
公钥加密

func RsaSign

func RsaSign(cipherText []byte, privateKey []byte) ([]byte, error)

* @param cipherText 待签名字段 RSA私钥签名sha1

func RsaSignPKCS8

func RsaSignPKCS8(cipherText []byte, privateKey []byte) ([]byte, error)

* @param cipherText 待签名字段 RSA私钥签名sha1

func RsaVerifySign

func RsaVerifySign(origData []byte, sign []byte, publicKey string) error

* @param origData 待签名字段 @param sign 签名 公钥验签

func Sha1

func Sha1(data []byte) [20]byte

func Sha256

func Sha256(data []byte) string

func Sm2Encrypt

func Sm2Encrypt(plaintext []byte, pubKeyBytes []byte, cipherTextType int) ([]byte, error)

func Sm4CbcPkcs5Decode

func Sm4CbcPkcs5Decode(data []byte, key []byte, iv []byte) ([]byte, error)

func Sm4CbcPkcs5Encode

func Sm4CbcPkcs5Encode(data []byte, key []byte, iv []byte) ([]byte, error)

func Sm4EcbPkcs5Decode

func Sm4EcbPkcs5Decode(data []byte, key []byte) ([]byte, error)

func Sm4EcbPkcs5Encode

func Sm4EcbPkcs5Encode(data []byte, key []byte) ([]byte, error)

func ToMd5

func ToMd5(str string) string

func TripleDesDecrypt

func TripleDesDecrypt(crypted, key, iv []byte) ([]byte, error)

3DES解密

func TripleDesEncrypt

func TripleDesEncrypt(origData, key, iv []byte) ([]byte, error)

3DES加密

func UnGzip

func UnGzip(compressSrc []byte) []byte

func UnicodeString

func UnicodeString(str string) string

func ZeroPadding

func ZeroPadding(ciphertext []byte, blockSize int) []byte

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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