easysdk

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: GPL-3.0 Imports: 22 Imported by: 0

README

easy-sdk-go Build Status

A set of simple functions to make life easier.

Install

go get -u "github.com/personal-security/easy-sdk-go"

Functions

Listing functions is dev.

  • MattermostSendMessage - Send message with hook to mattermost service

Import

import (
    easysdk "github.com/personal-security/easy-sdk-go"
)

Example Rest Answer

package controllers

import (
    "net/http"
    "rest-api/models"

    "github.com/gorilla/mux"
    easysdk "github.com/personal-security/easy-sdk-go"
)

var StatusGetNow = func(w http.ResponseWriter, r *http.Request) {
    // CODE

    resp := &easysdk.RespondApi{}
    resp.Create(true, "Success")
    resp.Respond(w)
}

or

package controllers

import (
    "net/http"
    "rest-api/models"

    "github.com/gorilla/mux"
    easysdk "github.com/personal-security/easy-sdk-go"
)

var StatusGetNow = func(w http.ResponseWriter, r *http.Request) {
    // CODE

    easysdk.GenerateApiRespond(w,true,"Success",nil)
}

pkg.go.dev

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptMailMessage

func EncryptMailMessage(key, body []byte) ([]byte, error)

EncryptMailMessage encrypts a mail with given public key.

func EncryptRC4

func EncryptRC4(data []byte, ciph *CipherRC4) []byte

func FileExists

func FileExists(filename string) bool

FileExists check is file exist

func FileStringReplace

func FileStringReplace(FilePath string, Original string, Replace string) error

func FileStringReplaceRegEx

func FileStringReplaceRegEx(FilePath string, RegEx string, Replace string) error

func FileWriteBytes

func FileWriteBytes(FilePath string, Data []byte) error

func FolderExist

func FolderExist(path string) (bool, error)

func GenerateApiError added in v0.0.6

func GenerateApiError(w http.ResponseWriter, message string, data map[string]interface{}, code int)

func GenerateApiErrorJson added in v0.0.6

func GenerateApiErrorJson(message string, data map[string]interface{}) string

func GenerateApiRespond added in v0.0.6

func GenerateApiRespond(w http.ResponseWriter, status bool, message string, data map[string]interface{})

func GenerateApiRespondJson added in v0.0.6

func GenerateApiRespondJson(status bool, message string, data map[string]interface{}) string

func GenerateUrlHash

func GenerateUrlHash() string

func GetMD5Hash

func GetMD5Hash(text string) string

GetMD5Hash generate md5 hash from string

func GetMD5HashByte

func GetMD5HashByte(text []byte) string

GetMD5Hash generate md5 hash from []byte

func GetProxyDial added in v0.1.0

func GetProxyDial(proxyModel *ProxyModel) proxy.Dialer

func GetRequest added in v0.0.9

func GetRequest(url string) ([]byte, int, error)

func GetRequestTimeout added in v0.0.9

func GetRequestTimeout(url string, timeout int, token string) ([]byte, int, error)

func GetRequestWithToken added in v0.0.9

func GetRequestWithToken(url string, token string) ([]byte, int, error)

func InsertIntoString

func InsertIntoString(s string, interval int, sep rune) string

func MakeSecureString

func MakeSecureString(text string) string

func MattermostSendMessage

func MattermostSendMessage(url, hook, message string, isCode bool, warning bool, proxyModel *ProxyModel) (string, error)

func Message

func Message(status bool, message string) map[string]interface{}

Message show message in request

func PgpDecryptMessage added in v0.0.2

func PgpDecryptMessage(text string, key string, pass string) (string, error)

PgpDecryptMessage decrypt message with private key (password optional)

func PgpEncrypt

func PgpEncrypt(publicKeyring string, secretString string) (string, error)

func PgpEncryptMessage added in v0.0.2

func PgpEncryptMessage(key, body []byte) ([]byte, error)

PgpEncryptMessage encrypt message with public pgp key

func RandIntBytes

func RandIntBytes(n int) string

func RandStringBytes

func RandStringBytes(n int) string

func RandStringBytesAllLower added in v0.0.8

func RandStringBytesAllLower(n int) string

func Respond

func Respond(w http.ResponseWriter, data map[string]interface{})

Respond add headers to respond

func ReverseFloat64

func ReverseFloat64(input []float64) []float64

func ReverseInts

func ReverseInts(input []int) []int

func ReverseStrings

func ReverseStrings(input []string) []string

func RunCMD

func RunCMD(Command string, Home string) (string, error)

func SendGetTorRequest

func SendGetTorRequest(url string) ([]byte, error)

func SendPostTorRequest

func SendPostTorRequest(url string, postData url.Values) ([]byte, error)

func SliceHaveString added in v0.0.3

func SliceHaveString(s []string, str string) bool

func StringBase64Rc4 added in v0.1.0

func StringBase64Rc4(data string, keyString string) string

StringBase64Rc4 encrypt string with key

func StringToFloat32

func StringToFloat32(text string) (float32, error)

func StringToFloat64

func StringToFloat64(text string) (float64, error)

func StringToUint

func StringToUint(text string) (uint, error)

func StringToUint64

func StringToUint64(text string) (uint64, error)

Types

type CipherRC4

type CipherRC4 struct {
	// contains filtered or unexported fields
}

func NewCipherRC4

func NewCipherRC4(key []byte) (*CipherRC4, error)

func (*CipherRC4) Reset

func (c *CipherRC4) Reset()

func (*CipherRC4) XorKeyStreamGeneric

func (c *CipherRC4) XorKeyStreamGeneric(dst, src []byte)

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

type ProxyModel added in v0.1.0

type ProxyModel struct {
	Protocol string
	Addr     string
	Port     int
	User     string
	Pass     string
}

type RespondApi added in v0.0.6

type RespondApi struct {
	// contains filtered or unexported fields
}

func (*RespondApi) Create added in v0.0.6

func (respond *RespondApi) Create(status bool, message string)

func (*RespondApi) Respond added in v0.0.6

func (respond *RespondApi) Respond(w http.ResponseWriter)

Return to browser

func (*RespondApi) ReturnHashMap added in v0.0.6

func (respond *RespondApi) ReturnHashMap() map[string]interface{}

func (*RespondApi) ReturnJson added in v0.0.6

func (respond *RespondApi) ReturnJson() string

func (*RespondApi) SetCode added in v0.0.7

func (respond *RespondApi) SetCode(code int)

Optional func

func (*RespondApi) SetMessage added in v0.0.6

func (respond *RespondApi) SetMessage(message string)

Optional func

func (*RespondApi) SetPayload added in v0.0.6

func (respond *RespondApi) SetPayload(data map[string]interface{})

Optional func

func (*RespondApi) SetStatus added in v0.0.6

func (respond *RespondApi) SetStatus(status bool)

Optional func

Jump to

Keyboard shortcuts

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