Documentation
¶
Index ¶
- func After(value string, a string) string
- func BcryptCompare(hash string, password string) error
- func BcryptHash(password string) (string, error)
- func Before(value string, a string) string
- func Between(value string, a string, b string) string
- func BytesFormat(inputNum float64, precision int) string
- func Contains(vals []string, s string) bool
- func ConvertToBool(value interface{}) bool
- func ConvertToFloat64(value interface{}) float64
- func ConvertToInteger(value interface{}) int
- func ConvertToString(value interface{}) string
- func DecodeBase64(str string) ([]byte, error)
- func DecodeURLBase64(str string) ([]byte, error)
- func Decrypt(ciphertext []byte, key []byte) (plaintext []byte, err error)
- func Deserialize(src []byte, dst interface{}) error
- func Difference(slice []string, slice2 []string) []string
- func EncodeBase64(str []byte) string
- func EncodeURLBase64(str []byte) string
- func Encrypt(plaintext []byte, key []byte) (ciphertext []byte, err error)
- func GetCookie(name string, request *http.Request) (string, error)
- func RandomBytes(length int) []byte
- func RandomString(length int) string
- func Serialize(src interface{}) ([]byte, error)
- func SetCookie(cookie http.Cookie, response http.ResponseWriter)
- func Size(value interface{}) float64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BcryptCompare ¶
BcryptCompare - compares a bcrypt hashed password with its possible plaintext equivalent. Returns nil on success, or an error on failure.
func BcryptHash ¶
BcryptHash - generate hashed password.
func BytesFormat ¶
BytesFormat - format bytes to MB...
func ConvertToBool ¶
func ConvertToBool(value interface{}) bool
ConvertToBool convert any data type to bool
func ConvertToFloat64 ¶
func ConvertToFloat64(value interface{}) float64
ConvertToFloat64 convert any data type to float64
func ConvertToInteger ¶
func ConvertToInteger(value interface{}) int
ConvertToInteger convert any data type to specific type
func ConvertToString ¶
func ConvertToString(value interface{}) string
ConvertToString convert any data type to specific type
func DecodeBase64 ¶
DecodeBase64 - decode base64 string
func DecodeURLBase64 ¶
DecodeURLBase64 - decode base64 string
func Decrypt ¶
Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.
Example ¶
key := []byte("9d8b23c2529ced916abaf60599fb3110") text, _ := hex.DecodeString("537235e0ba1c4551c1787ab68ceb4bc3c6e738f0e3b3e8656322932e2a56969b4bcf5afb53e07d082b5cd61e8a451433") doTest, _ := Decrypt(text, key) fmt.Printf("%s\n", doTest) // fmt.Println(err)
Output: Testing encrypt func
func Deserialize ¶
Deserialize decodes a value using gob.
Example ¶
key := []byte("9d8b23c2529ced916abaf60599fb3110") text, _ := hex.DecodeString("537235e0ba1c4551c1787ab68ceb4bc3c6e738f0e3b3e8656322932e2a56969b4bcf5afb53e07d082b5cd61e8a451433") doTest, _ := Decrypt(text, key) fmt.Printf("%s\n", doTest) // fmt.Println(err)
Output: Testing encrypt func
func Difference ¶
Difference - returns the values in slice1 that are not present in any of the other slices.
func EncodeBase64 ¶
EncodeBase64 - encode bytes to base64 string
func EncodeURLBase64 ¶
EncodeURLBase64 - encode bytes to base64 string
func Encrypt ¶
Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.
Example ¶
key := []byte("9d8b23c2529ced916abaf60599fb3110") text := []byte("Testing encrypt func") doTest, _ := Encrypt(text, key) fmt.Printf("%x\n", doTest)
Output:
func RandomString ¶
RandomString return random string by length
Types ¶
This section is empty.