crypto

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aes128CBCDecrypt added in v0.0.2

func Aes128CBCDecrypt(key [16]byte, ciphertext []byte) (plaintext []byte, err error)

Aes128CBCDecrypt aes-128-cbc 解密

func Aes128CBCEncrypt added in v0.0.2

func Aes128CBCEncrypt(key [16]byte, plaintext []byte) (ciphertext []byte, err error)

Aes128CBCEncrypt aes-128-cbc 加密

func Aes128CFBDecrypt added in v0.0.2

func Aes128CFBDecrypt(key [16]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes128CFBDecrypt aes-128-cfb 解密

func Aes128CFBEncrypt added in v0.0.2

func Aes128CFBEncrypt(key [16]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes128CFBEncrypt aes-128-cfb 加密

func Aes128CTRDecrypt added in v0.0.2

func Aes128CTRDecrypt(key [16]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes128CTRDecrypt aes-128-ctr 解密

func Aes128CTREncrypt added in v0.0.2

func Aes128CTREncrypt(key [16]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes128CTREncrypt aes-128-ctr 加密

func Aes128ECBDecrypt added in v0.0.2

func Aes128ECBDecrypt(key [16]byte, ciphertext []byte) (plaintext []byte, err error)

Aes128ECBDecrypt aes-128-ecb 解密

func Aes128ECBEncrypt added in v0.0.2

func Aes128ECBEncrypt(key [16]byte, plaintext []byte) (ciphertext []byte, err error)

Aes128ECBEncrypt aes-128-ecb 加密

func Aes128OFBDecrypt added in v0.0.2

func Aes128OFBDecrypt(key [16]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes128OFBDecrypt aes-128-ofb 解密

func Aes128OFBEncrypt added in v0.0.2

func Aes128OFBEncrypt(key [16]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes128OFBEncrypt aes-128-ofb 加密

func Aes192CBCDecrypt added in v0.0.2

func Aes192CBCDecrypt(key [24]byte, ciphertext []byte) (plaintext []byte, err error)

Aes192CBCDecrypt aes-192-cbc 解密

func Aes192CBCEncrypt added in v0.0.2

func Aes192CBCEncrypt(key [24]byte, plaintext []byte) (ciphertext []byte, err error)

Aes192CBCEncrypt aes-192-cbc 加密

func Aes192CFBDecrypt added in v0.0.2

func Aes192CFBDecrypt(key [24]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes192CFBDecrypt aes-192-cfb 解密

func Aes192CFBEncrypt added in v0.0.2

func Aes192CFBEncrypt(key [24]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes192CFBEncrypt aes-192-cfb 加密

func Aes192CTRDecrypt added in v0.0.2

func Aes192CTRDecrypt(key [24]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes192CTRDecrypt aes-192-ctr 解密

func Aes192CTREncrypt added in v0.0.2

func Aes192CTREncrypt(key [24]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes192CTREncrypt aes-192-ctr 加密

func Aes192ECBDecrypt added in v0.0.2

func Aes192ECBDecrypt(key [24]byte, ciphertext []byte) (plaintext []byte, err error)

Aes192ECBDecrypt aes-192-ecb 解密

func Aes192ECBEncrypt added in v0.0.2

func Aes192ECBEncrypt(key [24]byte, plaintext []byte) (ciphertext []byte, err error)

Aes192ECBEncrypt aes-192-ecb 加密

func Aes192OFBDecrypt added in v0.0.2

func Aes192OFBDecrypt(key [24]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes192OFBDecrypt aes-192-ofb 解密

func Aes192OFBEncrypt added in v0.0.2

func Aes192OFBEncrypt(key [24]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes192OFBEncrypt aes-192-ofb 加密

func Aes256CBCDecrypt added in v0.0.2

func Aes256CBCDecrypt(key [32]byte, ciphertext []byte) (plaintext []byte, err error)

Aes256CBCDecrypt aes-256-cbc 解密

func Aes256CBCEncrypt added in v0.0.2

func Aes256CBCEncrypt(key [32]byte, plaintext []byte) (ciphertext []byte, err error)

Aes256CBCEncrypt aes-256-cbc 加密

func Aes256CFBDecrypt added in v0.0.2

func Aes256CFBDecrypt(key [32]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes256CFBDecrypt aes-256-cfb 解密

func Aes256CFBEncrypt added in v0.0.2

func Aes256CFBEncrypt(key [32]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes256CFBEncrypt aes-256-cfb 加密

func Aes256CTRDecrypt added in v0.0.2

func Aes256CTRDecrypt(key [32]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes256CTRDecrypt aes-256-ctr 解密

func Aes256CTREncrypt added in v0.0.2

func Aes256CTREncrypt(key [32]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes256CTREncrypt aes-256-ctr 加密

func Aes256ECBDecrypt added in v0.0.2

func Aes256ECBDecrypt(key [32]byte, ciphertext []byte) (plaintext []byte, err error)

Aes256ECBDecrypt aes-256-ecb 解密

func Aes256ECBEncrypt added in v0.0.2

func Aes256ECBEncrypt(key [32]byte, plaintext []byte) (ciphertext []byte, err error)

Aes256ECBEncrypt aes-256-ecb 加密

func Aes256OFBDecrypt added in v0.0.2

func Aes256OFBDecrypt(key [32]byte, cipherReader io.Reader) (plainReader io.Reader, err error)

Aes256OFBDecrypt aes-256-ofb 解密

func Aes256OFBEncrypt added in v0.0.2

func Aes256OFBEncrypt(key [32]byte, plainReader io.Reader) (cipherReader io.Reader, err error)

Aes256OFBEncrypt aes-256-ofb 加密

func Base64Decode

func Base64Decode(raw []byte) []byte

Base64Decode base64解密

func Base64DecodeStr

func Base64DecodeStr(bs64str string) string

Base64DecodeStr base64字符串解密

func Base64Encode

func Base64Encode(raw []byte) []byte

Base64Encode base64加密

func Base64EncodeStr

func Base64EncodeStr(raw string) string

Base64EncodeStr base64字符串加密

func CRandBytes added in v0.0.9

func CRandBytes(numBytes int) []byte

This only uses the OS's randomness

func CRandHex added in v0.0.9

func CRandHex(numDigits int) string

CRandHex returns a hex encoded string that's floor(numDigits/2) * 2 long.

Note: CRandHex(24) gives 96 bits of randomness that are usually strong enough for most purposes.

func CReader added in v0.0.9

func CReader() io.Reader

Returns a crand.Reader.

func Convert16bytes added in v0.0.2

func Convert16bytes(b []byte) (b16 [16]byte)

Convert16bytes 将 []byte 转为 [16]byte

func Convert24bytes added in v0.0.2

func Convert24bytes(b []byte) (b24 [24]byte)

Convert24bytes 将 []byte 转为 [24]byte

func Convert32bytes added in v0.0.2

func Convert32bytes(b []byte) (b32 [32]byte)

Convert32bytes 将 []byte 转为 [32]byte

func DecryptAES

func DecryptAES(src []byte, key []byte) ([]byte, error)

解密

func EncryptAES

func EncryptAES(src []byte, key []byte) ([]byte, error)

加密

func HmacMD5 added in v0.0.2

func HmacMD5(key, origData []byte) (sum []byte)

HmacMD5 HMAC-SHA512-签名认证

func HmacSHA1 added in v0.0.2

func HmacSHA1(key, origData []byte) (sum []byte)

HmacSHA1 HMAC-SHA-1签名认证

func HmacSHA256 added in v0.0.2

func HmacSHA256(key, origData []byte) (sum []byte)

HmacSHA256 HMAC-SHA-256签名认证

func HmacSHA512 added in v0.0.2

func HmacSHA512(key, origData []byte) (sum []byte)

HmacSHA512 HMAC-SHA-512签名认证

func PKCS5Padding added in v0.0.2

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

PKCS5Padding PKCS5 Padding

func PKCS5UnPadding added in v0.0.2

func PKCS5UnPadding(plaintext []byte) []byte

PKCS5UnPadding PKCS5 UnPadding

func RsaDecrypt

func RsaDecrypt(privateKey, ciphertext []byte) ([]byte, error)

解密

func RsaEncrypt

func RsaEncrypt(publicKey, origData []byte) ([]byte, error)

加密

func Sha256 added in v0.0.9

func Sha256(bytes []byte) []byte

Types

type Address added in v0.0.9

type Address = bytes.HexBytes

An address is a []byte, but hex-encoded even in JSON. []byte leaves us the option to change the address length. Use an alias so Unmarshal methods (with ptr receivers) are available too.

type AesMode added in v0.0.2

type AesMode int

AesMode AES 工作模式

const (
	// AesECB ecb 模式
	AesECB AesMode = iota
	// AesCBC cbc 模式
	AesCBC
	// AesCTR ctr 模式
	AesCTR
	// AesCFB cfb 模式
	AesCFB
	// AesOFB ofb 模式
	AesOFB
)

type PrivKey added in v0.0.9

type PrivKey interface {
	Bytes() []byte
	Sign(msg []byte) ([]byte, error)
	PubKey() PubKey
	Equals(PrivKey) bool
	Type() string
}

type PubKey added in v0.0.9

type PubKey interface {
	Address() Address
	Bytes() []byte
	VerifySignature(msg []byte, sig []byte) bool
	Equals(PubKey) bool
	Type() string
}

type Symmetric added in v0.0.9

type Symmetric interface {
	Keygen() []byte
	Encrypt(plaintext []byte, secret []byte) (ciphertext []byte)
	Decrypt(ciphertext []byte, secret []byte) (plaintext []byte, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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