standard

package
v0.0.0-...-5f1ca4c Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

加密

加密解密在实际开发中应用比较广泛,常用加解密分为:

  • “对称式”
  • “非对称式”
  • ”数字签名“

对称式

对称加密(也叫私钥加密)指加密和解密使用相同密钥的加密算法。具体算法主要有DES算法,3DES算法,TDEA算法,Blowfish算法,RC5算法,IDEA算法。

非对称加密(公钥加密)

指加密和解密使用不同密钥的加密算法,也称为公私钥加密。具体算法主要有RSA、Elgamal、背包算法、Rabin、D-H、ECC(椭圆曲线加密算法)。

数字签名

数字签名是非对称密钥加密技术与数字摘要技术的应用。主要算法有md5、hmac、sha1等。

Documentation

Index

Constants

View Source
const (
	UTF8    = Charset("UTF-8")
	GB18030 = Charset("GB18030")
)

Variables

This section is empty.

Functions

func ConvertByte2String

func ConvertByte2String(byte []byte, charset Charset) string

func GetSha512Hash

func GetSha512Hash(data []byte) []byte

GetSha512Hash 获取sha512哈希

Types

type AesScheme

type AesScheme struct {
	OriginalAesKey string
	RealAesKey     []byte
	RealAesIv      []byte
}

func DefaultAesScheme

func DefaultAesScheme() *AesScheme

func NewAesScheme

func NewAesScheme(AesKey string) *AesScheme

func (*AesScheme) DecryptString

func (as *AesScheme) DecryptString(src string) (dst string, err error)

func (*AesScheme) EncryptString

func (as *AesScheme) EncryptString(src string) (dst string, err error)

type Charset

type Charset string

type CryptoScheme

type CryptoScheme struct {
	OriginalAesKey string
	RealAesKey     []byte
	RealAesIv      []byte
	// contains filtered or unexported fields
}

CryptoScheme 加密策略

func NewCryptoScheme

func NewCryptoScheme(publicKey string) *CryptoScheme

func (*CryptoScheme) CheckAes

func (s *CryptoScheme) CheckAes() (err error)

CheckAes 检查

func (*CryptoScheme) DecryptString

func (s *CryptoScheme) DecryptString(data string) (dst string, err error)

DecryptString 解密

func (*CryptoScheme) EncryptString

func (s *CryptoScheme) EncryptString(data string) (dst string, err error)

EncryptString 加密

func (*CryptoScheme) EqualAesKey

func (s *CryptoScheme) EqualAesKey(aesKey string) bool

EqualAesKey 对比aes 是否一致

func (*CryptoScheme) SetAesKey

func (s *CryptoScheme) SetAesKey(aesKey string) (bool, error)

SetAesKey 更新aes key

type CustomBase64

type CustomBase64 struct {
	// contains filtered or unexported fields
}

CustomBase64 自定义base64

func NewCustomBase64

func NewCustomBase64(base64Tables ...string) *CustomBase64

NewCustomBase64 新自定义base64

func (*CustomBase64) Decode

func (cb *CustomBase64) Decode(src []byte) ([]byte, error)

Decode 解码

func (*CustomBase64) Encode

func (cb *CustomBase64) Encode(src []byte) string

Encode 编码

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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