utils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const PrivateKeyPath = "key.rsa"
View Source
const PublicKeyPath = "key.rsa.pub"

Variables

This section is empty.

Functions

func Base16ToHex added in v0.4.0

func Base16ToHex(b string) string

Base16ToHex converts a string in base-16 to its hexadecimal representation.

func ExtractResponseData added in v0.3.0

func ExtractResponseData(res *http.Response) ([]byte, error)

ExtractResponseData reads the HTTP response body and returns it as a byte slice.

func LPad added in v0.3.0

func LPad(text string, n int, char string) string

LPad pads the input string `text` on the left with the specified `char` until it reaches the desired length `n`.

func RPad added in v0.3.0

func RPad(text string, n int, char string) string

RPad pads the input `text` on the right with the specified `char` until it reaches the desired length `n`.

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the contents of a file at the given path and returns the data as a byte slice or an error.

func SHA1Encode added in v0.3.0

func SHA1Encode(val []byte) []byte

SHA1Encode computes and returns the SHA-1 hash of the given byte slice.

func SaveKeys added in v0.4.0

func SaveKeys(keys Keys) error

SaveKeys saves the provided private and public keys to the respective file paths.

func WriteFile

func WriteFile(path string, content []byte) error

WriteFile writes the provided content into a file, create if it does not exist.

Types

type Keys added in v0.3.0

type Keys struct {
	PrivateKey []byte
	PublicKey  []byte
}

func GenerateKeys added in v0.3.0

func GenerateKeys() (Keys, error)

GenerateKeys generates a new RSA key pair, encodes them in PEM format.

func LoadKeys added in v0.4.0

func LoadKeys() (Keys, error)

LoadKeys loads the public and private keys from their respective file paths.

Jump to

Keyboard shortcuts

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