encrypt

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

************************** @File : SHA256Hash.go @Time : 2022/07/04 17:40:29 @AUTHOR : small_ant @Email : xms.chnb@gmail.com @Desc : sha256 ***************************

************************** @File : aes.go @Time : 2022/07/04 17:34:28 @AUTHOR : small_ant @Email : xms.chnb@gmail.com @Desc : aes encrypt ***************************

************************** @File : ecrecover.go @Time : 2022/03/29 17:59:39 @AUTHOR : small_ant @Email : xms.chnb@gmail.com @Desc : web3 sign ***************************

************************** @File : md5.go @Time : 2022/07/04 17:39:55 @AUTHOR : small_ant @Email : xms.chnb@gmail.com @Desc : md5 encrypt ***************************

Index

Constants

This section is empty.

Variables

View Source
var PwdKey = []byte("ABCDABCDABCDABCD")

16,24,32位字符串的话,分别对应AES-128,AES-192,AES-256 加密方法 key不能泄露

Functions

func AesDecrypt

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

AesDecrypt 解密 It decrypts the data using AES-CBC.

func AesEncrypt

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

AesEncrypt 加密 It takes a byte array and a key, and returns a byte array

func Base64Decode

func Base64Decode(str string) (string, []byte)
base64 解码

Decode a base64 string into a string and a byte array.

func Base64Encode

func Base64Encode(str []byte) string

base64 编码 Base64Encode takes a byte slice and returns a string.

func DecryptByAes

func DecryptByAes(data string) ([]byte, error)

DecryptByAes Aes 解密 It decrypts the data using AES.

func Ecrecover

func Ecrecover(hash, sig []byte) ([]byte, error)

Ecrecover returns the uncompressed public key that created the given signature.

func EncryptByAes

func EncryptByAes(data []byte) (string, error)

EncryptByAes Aes加密 后 base64 再加 Encrypts the data using AES and returns the encrypted data in base64 format.

func GetSHA256HashCode

func GetSHA256HashCode(message []byte) string

SHA256生成哈希值 It takes a byte array as input, and returns a string as output

func Md5Bytes

func Md5Bytes(b []byte) string

It takes a byte slice and returns a string

func Md5SaltString

func Md5SaltString(str, md5Salt string) string

生成32位md5 salt加密字符串 It takes a string and a salt, and returns the MD5 hash of the string concatenated with the salt

func Md5String

func Md5String(str string) string

生成32位md5字符串 It takes a string, creates a new MD5 hash, writes the string to the hash, and then returns the hexadecimal representation of the hash

func NullUnPadding

func NullUnPadding(in []byte) []byte

It removes all the null bytes from the end of the input byte array

func SigRSV

func SigRSV(isig interface{}) ([32]byte, [32]byte, uint8)

SigRSV signatures R S V returned as arrays

func SigToPub

func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)

SigToPub returns the public key that created the given signature.

func SignBuyOrder

func SignBuyOrder(hash string, key string) map[string]interface{}

func SignMint

func SignMint(address string, tokenId int64, key string) map[string]interface{}

It takes the address of the owner, the tokenId of the token to be minted, and the private key of the owner, and returns the signature of the minting transaction

func SignOrder

func SignOrder(data []byte) string

discard & 弃用

func SignTest

func SignTest()

It takes a message, hashes it, signs the hash with a private key, and returns the signature

func VerifySig

func VerifySig(from string, sigHex string, msg []byte) bool

It takes a message, a signature, and a public key, and returns true if the signature is valid for the message under the public key

func ZeroPadding

func ZeroPadding(in []byte) []byte

If the length of the input is a multiple of 8, return the input, otherwise return the input with enough zero bytes appended to make the length a multiple of 8

Types

This section is empty.

Jump to

Keyboard shortcuts

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