coder

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 23 Imported by: 1

README

coder

Documentation

Index

Constants

View Source
const (
	CBCMode = iota
	CFBMode
	CTRMode
	ECBMode
	OFBMode
)
View Source
const (
	PrintHex = iota
	PrintBase64
)
View Source
const (
	RSA_KEY_SIZE_256  = 256
	RSA_KEY_SIZE_512  = 512
	RSA_KEY_SIZE_1024 = 1024
	RSA_KEY_SIZE_2048 = 2048
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(content string, key string, iv string) string

func AesDecryptCBC added in v1.3.0

func AesDecryptCBC(content string, key string) string

func AesDecryptECB

func AesDecryptECB(content string, key string) string

AesDecryptECB 兼容java的AES解密方式

func AesEncrypt

func AesEncrypt(content string, key string, iv string) string

func AesEncryptCBC added in v1.3.0

func AesEncryptCBC(content string, key string) string

func AesEncryptECB

func AesEncryptECB(content string, key string) string

AesEncryptECB 兼容java的AES加密方式

func Base64Decrypt

func Base64Decrypt(content string) string

func Base64Encrypt

func Base64Encrypt(content string) string

func DESDecryptCBC

func DESDecryptCBC(content string, key string, iv string) string

func DESDecryptECB

func DESDecryptECB(content string, key string) string

func DESEncryptCBC

func DESEncryptCBC(content string, key string, iv string) string

func DESEncryptECB

func DESEncryptECB(content string, key string) string

func DSAGenerateKeyPair

func DSAGenerateKeyPair(size dsa.ParameterSizes, privateKeyPath string, publicKeyPath string) error

func DSASign

func DSASign(content string, privKeyPath string) (r, s *big.Int, err error)

func DSAVerify

func DSAVerify(content string, pubKeyPath string, r, s *big.Int) (bool, error)

func HMacMD5File

func HMacMD5File(filePath string, key string) (string, error)

func HMacMD5String

func HMacMD5String(s string, key string) string

func HMacSha1File

func HMacSha1File(filePath string, key string) (string, error)

func HMacSha1String

func HMacSha1String(s string, key string) string

func HMacSha256File

func HMacSha256File(filePath string, key string) (string, error)

func HMacSha256String

func HMacSha256String(s string, key string) string

func MD5File

func MD5File(filePath string) (string, error)

func MD5String

func MD5String(s string) string

func RC4Decrypt

func RC4Decrypt(content string, key string) string

func RC4Encrypt

func RC4Encrypt(content string, key string) string

func RSADecrypt

func RSADecrypt(content string, privateKeyPath string) (string, error)

func RSAEncrypt

func RSAEncrypt(content string, publicKeyPath string) (string, error)

func RSAGenerateKeyPair

func RSAGenerateKeyPair(size int, privateKeyPath string, publicKeyPath string) error

func Sha1File

func Sha1File(filePath string) (string, error)

func Sha1String

func Sha1String(s string) string

func Sha256File

func Sha256File(filePath string) (string, error)

func Sha256String

func Sha256String(s string) string

Types

type Cipher

type Cipher struct {
	GroupMode  int
	FillMode   FillMode
	DecodeType int
	Key        []byte
	Iv         []byte
	Output     CipherText
}

func (*Cipher) Decode

func (c *Cipher) Decode(cipherText string) ([]byte, error)

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(block cipher.Block, cipherData []byte) (err error)

func (*Cipher) Encode

func (c *Cipher) Encode() string

Encode default print format is base64

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(block cipher.Block, plainData []byte) (err error)

func (*Cipher) Fill

func (c *Cipher) Fill(plainText []byte, blockSize int) []byte

func (*Cipher) NewECBDecrypter

func (c *Cipher) NewECBDecrypter(block cipher.Block, cipherData []byte)

func (*Cipher) NewECBEncrypter

func (c *Cipher) NewECBEncrypter(block cipher.Block, plainData []byte)

func (*Cipher) UnFill

func (c *Cipher) UnFill(plainText []byte) (data []byte, err error)

type CipherText

type CipherText []byte

type Crypto

type Crypto interface {
	Encrypt(plainText []byte) (string, error)
	Decrypt(cipherText string) (string, error)
}

type FillMode

type FillMode int
const (
	PkcsZero FillMode = iota
	Pkcs7
)

Jump to

Keyboard shortcuts

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