helpers

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encrypt added in v1.1.0

func Encrypt(message, publicKey string, sdkSecretKey *[32]byte) (string, error)

Encrypt encrypts a message using the XSalsa20-Poly1305 cipher algorithm.

The `message` parameter represents the message to be encrypted. The `publicKey` parameter represents the base64-encoded public key of the merchant. The `sdkSecretKey` parameter represents the secret key generated in the current package.

Returns a base64-encoded string containing the encrypted message (box) and the used nonce. Returns an error if any issue occurs during the encryption process.

func GetKeyPair added in v1.1.0

func GetKeyPair() (publicKey *[32]byte, privateKey *[32]byte, err error)

GetKeyPair generates a new public/private key pair using the Curve25519 elliptic curve.

Returns a both public & private keys as a *[32]byte. Returns pointers to arrays of 32 bytes each for the public and private keys. The keys are generated in binary format.

func Hash

func Hash(algorithm, value string) string

This function returns a hash of a given value using the specified algorithm.

The `algorithm` parameter is the algorithm to use (e.g. "MD5", "SHA-1", "SHA-256"). The `value` parameter is the string to be hashed.

Returns the hash of the value parameter using the specified algorithm.

func ParseAmount

func ParseAmount(amount float64) string

ParseAmount parses or nullifies the given amount.

The `amount` parameter represents the amount to be parsed.

Returns a string that contains the parsed `amount`.

func ToJson

func ToJson(object interface{}) (string, error)

This function serializes the object to a JSON string and returns it as a string. If an error occurs during the process, it will be returned.

func TrimValue

func TrimValue(value string) string

TrimValue trims the given value.

The `value` parameter represents the input value to be trimmed.

Returns the trimmed version of the `value`.

func ValidateZeroValue added in v1.1.0

func ValidateZeroValue(value interface{}) bool

ValidateZeroValue checks if the value is the zero value for its type.

Returns a boolean evaluation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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