Documentation ¶
Index ¶
- Variables
- func AddKey(name string, key []byte) error
- type BlindIndexHash
- type BlindIndexStrong
- type EncryptedString
- func (e EncryptedString) Decrypt(ciphertext []byte) (string, error)
- func (e EncryptedString) Encrypt() ([]byte, error)
- func (e EncryptedString) MarshalJSON() ([]byte, error)
- func (e *EncryptedString) Scan(src interface{}) error
- func (e *EncryptedString) UnmarshalJSON(b64 []byte) error
- func (e EncryptedString) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrShortCipher = errors.New("ciphertext too short.") ErrVersionMismatch = errors.New("version mismatch.") ErrSrcNotBytes = errors.New("EncryptedString Scan src not a []byte.") ErrNoSuchKey = errors.New("No such key exists.") ErrKeyAlreadyExists = errors.New("Key with this name already exists.") )
Functions ¶
Types ¶
type BlindIndexHash ¶
type BlindIndexHash string
BlindIndexHash just does a sha512 HMAC hash. Good enough for queryable values that don't need to be crazy secure (most values), however these are NOT reversable. They are usually accompanied by an encrypted version though, so this is just to allow 1:1 queries. Note that the Valuer interface will hash the string autmatically if it is used as a bound parameter.
func (BlindIndexHash) GetBase64 ¶
func (b BlindIndexHash) GetBase64() (string, error)
GetBase64 returns the Base64 string value of the hashed value. Used for programmatically comparing values.
func (BlindIndexHash) GetHash ¶
func (b BlindIndexHash) GetHash() ([]byte, error)
type BlindIndexStrong ¶
type BlindIndexStrong string
BlindIndexStrong should only be used for extremely sensitive pieces of data that need to be 1:1 queried, such as an SSN. We usually don't store these types of values, so please use BlindIndexHash instead.
type EncryptedString ¶
type EncryptedString string
EncryptedString type is a string that will encrypt and decrypt on the fly when used with a database/sql/driver. It can also be encoding/json Marshaled and Unmarshaled with the same effect.
func (EncryptedString) Decrypt ¶
func (e EncryptedString) Decrypt(ciphertext []byte) (string, error)
Decrypt is used by the Scanner to decrypt the value incoming from the DB
func (EncryptedString) Encrypt ¶
func (e EncryptedString) Encrypt() ([]byte, error)
Encrypt encrypts the string using AES with GCM
func (EncryptedString) MarshalJSON ¶
func (e EncryptedString) MarshalJSON() ([]byte, error)
func (*EncryptedString) Scan ¶
func (e *EncryptedString) Scan(src interface{}) error
Scan calls decrypt on the string before
func (*EncryptedString) UnmarshalJSON ¶
func (e *EncryptedString) UnmarshalJSON(b64 []byte) error