utils

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BcryptHash

func BcryptHash(tohash []byte) ([]byte, error)

BcryptHash hashes a given byte array with bcrypt and a cost of 10

func BycrptVerify

func BycrptVerify(comparable, verifiable []byte) error

BycrptVerify compares a bcrypted comparable and its plain byte array

func DecodeBase32Key

func DecodeBase32Key(encodedKey string) ([]byte, error)

DecodeBase32Key Decodes a base32 encoded key to a byte array

func Decrypt

func Decrypt(data, passphrase []byte) []byte

Decrypt takes in two byte arrays. The former one is the encrypted data, the second one is the passphrase that shall be used. The method returns the decrypted data in another byte array Attention: It is assumed that a nonce is appended to the encrypted byte array!

func DecryptFile

func DecryptFile(filePath string, passphrase []byte) []byte

DecryptFile takes a filePath as a string and a passphrase as a byte array. The file found at filePath is then decrypted using the Decrypt Method and then wrote back to the original filePath

func Encrypt

func Encrypt(data, passphrase []byte) []byte

Encrypt takes in a byte array as data and another byte array as the passphrase, encrypts the data using the AES cipher and returns the encrypted data (also as byte array) please note that the nonce needed to encrypt the data using AES GCM is appended to the byte array

func EncryptFile

func EncryptFile(filePath string, data, passphrase []byte)

EncryptFile takes a filePath as a string and a passphrase as a byte array. The file found at filePath is then Encrypted using the Encrypt Method and then wrote back to the original filePath

func GenerateCryptedKeyBase32

func GenerateCryptedKeyBase32(rootKey []byte) (string, error)

GenerateCryptedKeyBase32 generates a new Key, encrypts it with the root key and encodes it to base32

func GenerateExtendedKeyBase32

func GenerateExtendedKeyBase32() (string, error)

GenerateExtendedKeyBase32 returns a base32 encoded 256bit key

func ScrubInformation

func ScrubInformation(user *structs.User, key *[]byte)

ScrubInformation crubs some sensitive information from the objects and nullifies the given byte array

func ScrubIssuerStruct

func ScrubIssuerStruct(issuer *structs.Issuer)

ScrubIssuerStruct scrubs the key of the issuer

func ScrubKey

func ScrubKey(key *[]byte)

ScrubKey nullifies a given byte array

func ScrubUserStruct

func ScrubUserStruct(user *structs.User)

ScrubUserStruct scrubs the key of the user and also the issuer key

Types

This section is empty.

Jump to

Keyboard shortcuts

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