crypthelp

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: MIT Imports: 16 Imported by: 0

README

crypthelp

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNilArgument       = errors.New("Required argument was nil")
	ErrorSeekRestoreFailed = errors.New("Restoring previous file position failed")
	TempDir                string
)

Functions

func Encrypt

func Encrypt(input []byte, entityList []*openpgp.Entity) ([]byte, error)

Encrypt will encrypt a []byte with the To being the array of openpgp.Entities passed in. Encrypt uses a temporary file with the default of "/tmp/". If you need to modify this set cryptohelp.TempDir = "/your/path/here"

func EncryptFile

func EncryptFile(inputFile *os.File, outputFile *os.File, entityList []*openpgp.Entity) (err error)

Encrypt will encrypt a file on the filesystem and write to the outputFile with the To being the array of openpgp.Entities passed in.

func HashFileMD5

func HashFileMD5(file *os.File) ([]byte, error)

HashFileMD5 will obtain an MD5 hash of the *os.File passed. *os.File's Seek position will automatically be moved to Seek(0,0) and a best effort will be used to restore the file's position after obtaining the hash. It returns a []byte containing the hash. If setting the previous Seek() fails the HASH will be valid but an error ErrorSeekRestoreFailed will also be included.

func HashFileSHA1

func HashFileSHA1(file *os.File) ([]byte, error)

HashFileSHA1 will obtain an SHA1 hash of the *os.File passed. *os.File's Seek position will automatically be moved to Seek(0,0) and a best effort will be used to restore the file's position after obtaining the hash. It returns a []byte containing the hash. If setting the previous Seek() fails the HASH will be valid but an error may also be returned.

func HashFileSHA256

func HashFileSHA256(file *os.File) ([]byte, error)

HashFileSHA256 will obtain an SHA256 hash of the *os.File passed. *os.File's Seek position will automatically be moved to Seek(0,0) and a best effort will be used to restore the file's position after obtaining the hash. It returns a []byte containing the hash. If setting the previous Seek() fails the HASH will be valid but an error ErrorSeekRestoreFailed will also be included.

func HashFileSHA512

func HashFileSHA512(file *os.File) ([]byte, error)

HashFileSHA512 will obtain an SHA512 hash of the *os.File passed. *os.File's Seek position will automatically be moved to Seek(0,0) and a best effort will be used to restore the file's position after obtaining the hash. It returns a []byte containing the hash. If setting the previous Seek() fails the HASH will be valid but an error ErrorSeekRestoreFailed will also be included.

func HashMD5

func HashMD5(filePath string) ([]byte, error)

HashMD5 returns MD5 hash for the file at the given path The returned hash is a byte array.

func HashSHA1

func HashSHA1(filePath string) ([]byte, error)

HashSHA1 returns SHA1 hash for the file at the given path The returned hash is a byte array.

func HashSHA256

func HashSHA256(filePath string) ([]byte, error)

Hash256 returns SHA256 hash for the file at the given path The returned hash is a byte array.

func HashSHA512

func HashSHA512(filePath string) ([]byte, error)

Hash512 returns SHA512 hash for the file at the given path The returned hash is a byte array.

func ReadPublicKey

func ReadPublicKey(key []byte) (*openpgp.Entity, error)

ReadPublicKey will convert a []byte into an *openpgp.Entity

func ReadPublicKeyFile

func ReadPublicKeyFile(keyPath string) (*openpgp.Entity, error)

OpenPGPEntity obtains an *openpgp.Entity for the PGP key file stored on disk or HTTP

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