crypto

package
v0.0.0-...-b8b82af Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPass

func CheckPass(ps string, id int, perms int) bool

CheckPass takes argument ps(string),id(int), perms(int). Where: ps is the password in string form, id is the id of the post and perms is the post permissions it returns a bool based on it's success

func EncryptBytes

func EncryptBytes(b []byte, key *[32]byte) (ct []byte, err error)

EncryptBytes is used to encrypt bytes with a key, pretty self-explanatory.. takes a byte slice b and a pointer to a 32 byte array key returns a byte slice (ct) and a error (err)

func GetEncKey

func GetEncKey(post *model.Post) (key [32]byte)

GetEncKey gets the encryption key used for the file by decrypting the stored-key with the passord scrypt-hash takes a pointer to model.Post as the only argument

and returns a 32 length byte array

func GetToken

func GetToken() string

GetToken generates a random token used to prefent CSRF attacks

func RequestDecrypt

func RequestDecrypt(post *model.Post) bool

RequestDecrypt decrypts the post if the field post.Crypto.Hash is the correct password. It takes a pointer to the model.Post as the only argument and returns a bool based on if the post is successfully decrypted

func SecurePost

func SecurePost(post *model.Post, pass string)

SecurePost generates a secure post for a unencrypted post. encryption varies based upon PostPerms takes a pointer to model.Post and a unencrypted password-string as arguments returns nothing

Types

This section is empty.

Jump to

Keyboard shortcuts

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