enctypthelper

package
v0.0.0-...-b952f1b Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeString

func DecodeString(key string) ([]byte, error)

func Decrypt

func Decrypt(pubKey *rsa.PrivateKey, message []byte) ([]byte, error)

func EncodeToString

func EncodeToString(data []byte) string

func Encrypt

func Encrypt(pubKey *rsa.PublicKey, message []byte) ([]byte, error)

func FnvHash

func FnvHash(s string) (uint32, error)

func GenerateSecretKey

func GenerateSecretKey() (*rsa.PrivateKey, error)

func Md5Encrypt

func Md5Encrypt(data []byte) string

func Sha1

func Sha1(key string) []byte

func Sha256

func Sha256(key string) []byte

Types

type AesEncrypt

type AesEncrypt struct {
	SecretKey string
}

func NewAesEncrypt

func NewAesEncrypt(key string) *AesEncrypt

func (*AesEncrypt) Decrypt

func (a *AesEncrypt) Decrypt(data []byte) ([]byte, error)

func (*AesEncrypt) Encrypt

func (a *AesEncrypt) Encrypt(data []byte) ([]byte, error)

func (*AesEncrypt) PKCS7Padding

func (a *AesEncrypt) PKCS7Padding(ciphertext []byte, blockSize int) []byte

PKCS7Padding 补码

func (*AesEncrypt) PKCS7UnPadding

func (a *AesEncrypt) PKCS7UnPadding(origData []byte) []byte

PKCS7UnPadding 去码

type BaseEncrypt

type BaseEncrypt struct{}

func (*BaseEncrypt) Decrypt

func (*BaseEncrypt) Decrypt(data []byte) ([]byte, error)

func (*BaseEncrypt) Encrypt

func (*BaseEncrypt) Encrypt(data []byte) ([]byte, error)

type IEncrypt

type IEncrypt interface {
	Encrypt([]byte) ([]byte, error)
	Decrypt([]byte) ([]byte, error)
}

type Linear

type Linear struct {
	A   *big.Int
	B   *big.Int
	Mod *big.Int
}

func NewLinear

func NewLinear(a, b, mod int64) Linear

func (Linear) CalculateA

func (l Linear) CalculateA() int64

CalculateA 线性混淆A值确定

func (Linear) Decrypt

func (l Linear) Decrypt(id int64) int64

Decrypt 在线性映射中,假设我们知道 a、b、m以及new_id,并希望计算原始的 id。 new_id = (a * id + b) % m 这是一个模运算,当且仅当 a 和 m 互质时,才可能对其进行逆操作找到原始的 id。 假设 a 和 m 是互质的,那么 a 逆元存在,记作 a’,满足 (a * a’) % m = 1。因此,就可以计算出 id = (a’ * (new_id - b)) % m。 计算 a’ 的方法是使用扩展欧几里得算法。

func (Linear) Encrypt

func (l Linear) Encrypt(id int64) int64

type Rsa2

type Rsa2 struct {
	PrivateKey *rsa.PrivateKey
}

func NewRsa2

func NewRsa2() *Rsa2

func (*Rsa2) Encrypt

func (r *Rsa2) Encrypt(data []byte) ([]byte, error)

func (*Rsa2) LoadPrivateKey

func (r *Rsa2) LoadPrivateKey(privateKey string) error

type XteaEncrypt

type XteaEncrypt struct {
	SecretKey string
}

func NewXteaEncrypt

func NewXteaEncrypt(key string) *XteaEncrypt

func (*XteaEncrypt) Decrypt

func (x *XteaEncrypt) Decrypt(data []byte) ([]byte, error)

func (*XteaEncrypt) Encrypt

func (x *XteaEncrypt) Encrypt(data []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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