Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SecureParse ¶
SecureParse is a shorthand for serializer := NewSecureSerializer(...) serializer.Parse(...)
Types ¶
type SecureSerializer ¶
SecureSerializer holds EncryptKey and ValidateKey
func NewSecureSerializer ¶
func NewSecureSerializer(encryptKey []byte, validateKey []byte) *SecureSerializer
NewSecureSerializer creates new serializer instance with encrypt key and validate key
Example ¶
serializer := NewSecureSerializer([]byte("somesecretkey"), []byte("anothersecretstring")) data := map[string]string{ "foo": "bar", } encryptedData, _ := serializer.Stringify(data) var returnedData map[string]string serializer.Parse(encryptedData, &returnedData) fmt.Printf("%v\n", returnedData)
Output: map[foo:bar]
func (*SecureSerializer) Parse ¶
func (serializer *SecureSerializer) Parse(serializedData string, obj interface{}) (err error)
Parse deserializes and decrypts encrypted data (returned by Stringify) to a pointer
func (*SecureSerializer) Stringify ¶
func (serializer *SecureSerializer) Stringify(obj interface{}) (string, error)
Stringify serializes and encrypts interface{} given as argument and returns encrypted data as a string or an possible error
Click to show internal directories.
Click to hide internal directories.