serializer

package module
v0.0.0-...-a4e6935 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: BSD-2-Clause Imports: 14 Imported by: 0

README

Build Status

serializer

Documentation https://gowalker.org/github.com/Applifier/serializer

Go port of https://github.com/AF83/node-serializer to enable decrypting data encrypted with node-serializer in node

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SecureParse

func SecureParse(data string, obj interface{}, encryptKey []byte, validateKey []byte) error

SecureParse is a shorthand for serializer := NewSecureSerializer(...) serializer.Parse(...)

func SecureStringify

func SecureStringify(obj interface{}, encryptKey []byte, validateKey []byte) (string, error)

SecureStringify is a shorthand for serializer := NewSecureSerializer(...) encryptedData := serializer.Stringify(...)

Types

type SecureSerializer

type SecureSerializer struct {
	EncryptKey  []byte
	ValidateKey []byte
}

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

Jump to

Keyboard shortcuts

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