utils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2018 License: MIT Imports: 23 Imported by: 0

README

utils
Code Coverage Code Coverage

This is a bunch of useful utilities I often use in Golang programs / stuff I saved from SO.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressAndEncryptBytesToFile

func CompressAndEncryptBytesToFile(inputBytes []byte, outputFilename string, password string) (err error)

CompressAndEncryptBytesToFile will compress and then encrypt files to bytes.

func CompressByte

func CompressByte(src []byte) []byte

CompressByte returns a compressed byte slice.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Copy the file contents from src to dst. from http://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func CryptReaderToWriter

func CryptReaderToWriter(src io.Reader, dst io.Writer, password string, encrypt bool) (err error)

CryptReaderToWriter will take inputbytes and output them to a file

func DecompressByte

func DecompressByte(src []byte) []byte

DecompressByte returns a decompressed byte slice.

func Decrypt

func Decrypt(data []byte, passphrase []byte) (plaintext []byte, err error)

Decrypt takes encrypted byte and a passphrase, with salt, and iv to decrypt.

func DecryptAndDecompressBytesFromFile

func DecryptAndDecompressBytesFromFile(inputFilename string, password string) (output []byte, err error)

DecryptAndDecompressBytesFromFile will take a file and decrypt them.

func DecryptBytesFromFile

func DecryptBytesFromFile(inputFilename string, password string) (output []byte, err error)

DecryptBytesFromFile will take a file and decrypt them into bytes.

func DecryptFile

func DecryptFile(inputFilename string, outputFilename string, password string) error

func Dos2Unix

func Dos2Unix(b []byte) []byte

Dos2Unix

func Encrypt

func Encrypt(plaintext []byte, passphrase []byte) (encrypted []byte)

Encrypt will encrypt using a passphrase.

func EncryptBytesToFile

func EncryptBytesToFile(inputBytes []byte, outputFilename string, password string) (err error)

EncryptBytesToFile will take inputbytes and output them to a file

func EncryptFile

func EncryptFile(inputFilename string, outputFilename string, password string) error

func Exists

func Exists(path string) bool

Exists returns whether the given file or directory exists or not from http://stackoverflow.com/questions/10510691/how-to-check-whether-a-file-or-directory-denoted-by-a-path-exists-in-golang

func Filemd5Sum

func Filemd5Sum(pathToFile string) (result string, err error)

Filemd5Sum returns the md5 sum of a file and produces the same hash for both Windows and Unix systems.

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns the local ip address

func GetRandomName

func GetRandomName() string

GetRandomName returns a random encoded name

func Hash

func Hash(data string) string

func HashBytes

func HashBytes(data []byte) string

func Md5Sum

func Md5Sum(s string) (result string)

func RandStringBytesMaskImprSrc

func RandStringBytesMaskImprSrc(n int) string

RandStringBytesMaskImprSrc prints a random string

func UserHomeDir

func UserHomeDir() string

UserHomeDir returns the user home directory taken from go1.8c2 https://stackoverflow.com/a/41786440

Types

This section is empty.

Jump to

Keyboard shortcuts

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