helpers

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 21 Imported by: 1

README

Go Functions Helper

Installation

go get github.com/Girein/helpers-go

Functions

// ToDateTimeString converts DateTime into string with Y-m-d H:i:s format
func ToDateTimeString(dateTime time.Time) string {}

// LogIfError logs the error with message
func LogIfError(err error, message string) {}

// RandomString generates random string with custom length
func RandomString(length int) string {}

// RandomInteger returns random integer between parameters
func RandomInteger(min int, max int) int {}

// JSONEncode converts data into JSON string
func JSONEncode(data interface{}) (string, error) {}

// InArray checks if a value exists in an array
func InArray(needle string, haystack []interface{}) bool {}

// AESEncrypt encrypts text using cipher AES/ECB/PKCS5PADDING
func AESEncrypt(text string, key []byte) (string, error) {}

// RSAVerifySignature verifies RSA PKCS #1 v1.5 signature with SHA256 hashing
func RSAVerifySignature(publicKey string, signature string, message string) (bool, error) {}

// RandomBytes generates random byte with custom length
func RandomBytes(n int) ([]byte, error) {}

// OpenSSLEncrypt encrypts given data with given key, returns base64 encoded string
func OpenSSLEncrypt(data []byte, passphrase []byte, iv []byte) (string, error) {}

// ComputeHMACSHA256 hashes given message with given secret, returns hexadecimal encoded string
func ComputeHMACSHA256(message string, secret string) (string, error) {}

// LaravelEncrypt encrypts the given value using Laravel's encrypter (https://laravel.com/docs/6.x/encryption)
func LaravelEncrypt(value string) (string, error) {}

// LaravelDecrypt decrypts the given value using Laravel's encrypter (https://laravel.com/docs/6.x/encryption)
func LaravelDecrypt(value string) (string, error) {}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESEncrypt added in v1.0.7

func AESEncrypt(text string, key []byte) (string, error)

AESEncrypt encrypts text using cipher AES/ECB/PKCS5PADDING

func ComputeHMACSHA256 added in v1.3.0

func ComputeHMACSHA256(message string, secret string) (string, error)

ComputeHMACSHA256 hashes given message with given secret, returns hexadecimal encoded string

func InArray added in v1.0.6

func InArray(needle string, haystack []interface{}) bool

InArray checks if a value exists in an array

func JSONEncode added in v1.0.5

func JSONEncode(data interface{}) (string, error)

JSONEncode converts data into JSON string

func LaravelDecrypt added in v1.3.0

func LaravelDecrypt(value string) (string, error)

LaravelDecrypt decrypts the given value using Laravel's encrypter (https://laravel.com/docs/6.x/encryption)

func LaravelEncrypt added in v1.3.0

func LaravelEncrypt(value string) (string, error)

LaravelEncrypt encrypts the given value using Laravel's encrypter (https://laravel.com/docs/6.x/encryption)

func LogIfError added in v1.0.4

func LogIfError(err error, message string)

LogIfError logs the error with message

func NewECBEncrypter added in v1.0.7

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

NewECBEncrypter returns a BlockMode which encrypts in ecb mode, using the given Block

func OpenSSLEncrypt added in v1.3.0

func OpenSSLEncrypt(data []byte, passphrase []byte, iv []byte) (string, error)

OpenSSLEncrypt encrypts given data with given key, returns base64 encoded string

func PKCS5Padding added in v1.0.7

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding adds PKCS5 padding

func RSAVerifySignature added in v1.0.9

func RSAVerifySignature(publicKey string, signature string, message string) (bool, error)

RSAVerifySignature verifies RSA PKCS #1 v1.5 signature with SHA256 hashing

func RandomBytes added in v1.3.0

func RandomBytes(n int) ([]byte, error)

RandomBytes generates random byte with custom length

func RandomInteger added in v1.0.4

func RandomInteger(min int, max int) int

RandomInteger returns random integer between parameters

func RandomString added in v1.0.4

func RandomString(n int) string

RandomString generates random string with custom length

func ToDateTimeString

func ToDateTimeString(dateTime time.Time) string

ToDateTimeString converts DateTime into string with Y-m-d H:i:s format

Types

type Unsigner added in v1.0.9

type Unsigner interface {
	Unsign(message []byte, signature []byte) error
}

Jump to

Keyboard shortcuts

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