util

package
v0.0.0-...-d7ff5e6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const BaseDecimal int64 = 18

BaseDecimal decimal for base token

Variables

This section is empty.

Functions

func BytesToPrivateKey

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

BytesToPrivateKey bytes to private key

func BytesToPublicKey

func BytesToPublicKey() (*rsa.PublicKey, error)

BytesToPublicKey bytes to public key

func DecodeAscii85

func DecodeAscii85(value string) (string, error)

DecodeAscii85 ascii85 decode

func DecodeBase64

func DecodeBase64(value string) (string, error)

DecodeBase64 base64 encryption

func DecodeSigningKey

func DecodeSigningKey(rawTx string) (map[string]interface{}, error)

DecodeSigningKey

func Decrypt

func Decrypt(value string) (string, error)

Decrypt function

func DecryptWithPrivateKey

func DecryptWithPrivateKey(ciphertext string) (string, error)

DecryptWithPrivateKey decrypts data with private key [only work with DecryptOAEP]

func EncodeAscii85

func EncodeAscii85(value string) string

EncodeAscii85 ascii85 encode

func EncodeBase32

func EncodeBase32(value string) string

EncodeBase32 base64 encryption

func EncodeBase64

func EncodeBase64(value string) string

EncodeBase64 base64 encryption example output: ZmVmZHNjZmZmZg==

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 md5 encryption

func Encrypt

func Encrypt(value string) (string, error)

Encrypt function example output: 31595d35a8f1fe9a3a10712b725e37d370e66ab824f3effe71c03935db68127f

func EncryptWithPublicKey

func EncryptWithPublicKey(msg []byte) (string, error)

EncryptWithPublicKey encrypts data with public key [only work with EncryptOAEP]

func GenerateHmacSHA256

func GenerateHmacSHA256(secret, data, result string) string

func GenerateScryptValue

func GenerateScryptValue(value []byte, salt string) ([]byte, error)

func GenerateScrypt. Can refer https://github.com/elithrar/simple-scrypt/blob/master/scrypt.go

func GetPage

func GetPage(c *gin.Context) int

GetPage get page parameters

func RsaDecryptPKCS1v15

func RsaDecryptPKCS1v15(encryptedText string) (string, error)

func RsaDecryptPKCS1v15 will work with DecryptPKCS1v15 can refer more detail in https://gist.github.com/hothero/93c69bbd57001ce0a1997f5dd1ba89f6

func RsaEncryptPKCS1v15

func RsaEncryptPKCS1v15(plainText string) (string, error)

func RsaEncryptPKCS1v15 will work with EncryptPKCS1v15 can refer more detail in https://gist.github.com/hothero/93c69bbd57001ce0a1997f5dd1ba89f6

func SendERC20

func SendERC20(chainID int64, privateKey, to, contractAddress string, nonce, maxGas uint64, value float64, decimal int64) (string, error)

SendERC20 func sending ERC20 token, can be used for LIGA / PAC token which follow ERC20 format

func SignTransaction

func SignTransaction(chainID int64, privateKey, to string, nonce, maxGas uint64, value float64, data []byte) (string, error)

SignTransaction sign eth transaction

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Scope []string    `json:"scope"`
	Data  interface{} `json:"data"`
}

func ParseToken

func ParseToken(token string) (*Claims, error)

// ParseToken parsing token

type PHCryReturnStruct

type PHCryReturnStruct struct {
	AddrInfo1 struct {
		Addr     string
		Scrypted string
	}
	AddrInfo2 struct {
		Addr     string
		Scrypted string
	}
}

func PHCry

func PHCry(value string) *PHCryReturnStruct

PHCry

type TokenDetails

type TokenDetails struct {
	Token   string
	Scope   []string
	UUID    string
	Expires int64
}

// TokenDetails struct

func GenerateAccessToken

func GenerateAccessToken(scope []string, subID, memberCode, username string, expires time.Duration) (*TokenDetails, error)

GenerateAccessToken generate tokens used for auth

func GenerateRefreshToken

func GenerateRefreshToken(scope []string, subID string, expires time.Duration) (*TokenDetails, error)

GenerateRefreshToken generate tokens used for auth

func GenerateToken

func GenerateToken(uuid string, subID string, expires time.Time, scope []string, tokenType string, data map[string]interface{}) (*TokenDetails, error)

func GenerateToken

Jump to

Keyboard shortcuts

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