securejsondata

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(payload []byte, secret string) ([]byte, error)

Decrypt decrypts a payload with a given secret.

func Encrypt

func Encrypt(payload []byte, secret string) ([]byte, error)

Encrypt encrypts a payload with a given secret.

func GetRandomString

func GetRandomString(n int, alphabets ...byte) (string, error)

GetRandomString generate random string by specify chars. source: https://github.com/gogits/gogs/blob/9ee80e3e5426821f03a4e99fad34418f5c736413/modules/base/tool.go#L58

func InitSecretKey

func InitSecretKey(key string)

func SecretKey

func SecretKey() string

Types

type SecureJsonData

type SecureJsonData map[string][]byte

SecureJsonData is used to store encrypted data (for example in data_source table). Only values are separately encrypted.

func GetEncryptedJsonData

func GetEncryptedJsonData(sjd map[string]string) SecureJsonData

GetEncryptedJsonData returns map where all keys are encrypted.

func (SecureJsonData) Decrypt

func (s SecureJsonData) Decrypt() map[string]string

Decrypt returns map of the same type but where the all the values are decrypted. Opposite of what GetEncryptedJsonData is doing.

func (SecureJsonData) DecryptedValue

func (s SecureJsonData) DecryptedValue(key string) (string, bool)

DecryptedValue returns single decrypted value from SecureJsonData. Similar to normal map access second return value is true if the key exists and false if not.

Jump to

Keyboard shortcuts

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