util

package
v0.0.0-...-9082c2d Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2016 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(msg []byte) []byte

Decrypts a message with RSA using the package global key.

func DecryptString

func DecryptString(msg string) string

Decrypts a string using the package global key.

func Encrypt

func Encrypt(msg []byte) []byte

Encrypts a message with RSA using the package global key.

func EncryptString

func EncryptString(msg string) string

Encrypts a string using the package global key.

func GenerateKey

func GenerateKey() string

Generates an RSA key (2048 bit) and encodes it using PEM.

func GeneratePlaceholders

func GeneratePlaceholders(start, end uint) string

Generates placeholders from start to end for an SQL query.

func GetPublicKey

func GetPublicKey(key *rsa.PrivateKey) string

Gets the public part of a private key in OpenSSL format.

func ParsePrivateKey

func ParsePrivateKey(key string) *rsa.PrivateKey

Parses a PEM private key. Returns nil on failure.

func RandomSecret

func RandomSecret(length int) string

RandomSecret generates a random secret of length bytes long.

The returned data will be hex encoded, so it will be length*2 characters.

func RandomStringGenerator

func RandomStringGenerator() func(length int) string

Creates a function that generates random strings with a given length.

The generated function is not thread-safe. This function is not secure. Use this for dummy info or temp files, but DO NOT use this to generate passwords or other cryptographically sensitive data.

func ResponseBodyToString

func ResponseBodyToString(r *http.Response) string

Reads the whole response body and converts it to a string.

func SetKey

func SetKey(key []byte) error

Sets the package global secret. The size of the secret should be 32 bytes. See Encrypt() and Decrypt()

func StringSliceToInterfaceSlice

func StringSliceToInterfaceSlice(s []string) []interface{}

Converts a string slice into an interface{} slice.

func StripTerminalColorCodes

func StripTerminalColorCodes(s string) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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