Documentation ¶
Index ¶
- type ASN1Serializer
- type GOBSerializer
- type JSONSerializer
- type SecureBytes
- func (sb *SecureBytes) Decrypt(data []byte, output interface{}) error
- func (sb *SecureBytes) DecryptBase64(b64 string, output interface{}) error
- func (sb *SecureBytes) Encrypt(input interface{}) ([]byte, error)
- func (sb *SecureBytes) EncryptToBase64(input interface{}) (string, error)
- func (sb *SecureBytes) RawDecrypt(data []byte) ([]byte, error)
- func (sb *SecureBytes) RawDecryptBase64(b64 string) ([]byte, error)
- func (sb *SecureBytes) RawEncrypt(data []byte) ([]byte, error)
- func (sb *SecureBytes) RawEncryptToBase64(data []byte) (string, error)
- type Serializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASN1Serializer ¶ added in v0.1.1
type ASN1Serializer struct{}
ASN1Serializer uses encoding/asn1 to encode and decode data
func (ASN1Serializer) Marshal ¶ added in v0.1.1
func (a ASN1Serializer) Marshal(v interface{}) ([]byte, error)
Marshal data with asn1 serializer
func (ASN1Serializer) Unmarshal ¶ added in v0.1.1
func (a ASN1Serializer) Unmarshal(data []byte, v interface{}) error
Unmarshal data with asn1 serializer
type GOBSerializer ¶
type GOBSerializer struct{}
GOBSerializer uses encoding/gob to encode and decode data
func (GOBSerializer) Marshal ¶ added in v0.1.1
func (g GOBSerializer) Marshal(v interface{}) ([]byte, error)
Marshal data with gob serializer
func (GOBSerializer) Unmarshal ¶ added in v0.1.1
func (g GOBSerializer) Unmarshal(data []byte, v interface{}) error
Unmarshal data with gob serializer
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer uses encoding/json to encode and decode data
func (JSONSerializer) Marshal ¶ added in v0.1.1
func (j JSONSerializer) Marshal(v interface{}) ([]byte, error)
Marshal data with json serializer
func (JSONSerializer) Unmarshal ¶ added in v0.1.1
func (j JSONSerializer) Unmarshal(data []byte, v interface{}) error
Unmarshal data with json serializer
type SecureBytes ¶
type SecureBytes struct { Serializer Serializer // contains filtered or unexported fields }
SecureBytes keeps encryption key and serializer.
func New ¶
func New(key []byte, serializer Serializer) *SecureBytes
New returns a new SecureBytes with JSONSerializer. `key` should provide 256 bits entropy, so if you are using random alphanumeric characters it should have a length of at least 50 characters.
func (*SecureBytes) Decrypt ¶
func (sb *SecureBytes) Decrypt(data []byte, output interface{}) error
Decrypt decrypts data encrypted by Encrypt.
func (*SecureBytes) DecryptBase64 ¶
func (sb *SecureBytes) DecryptBase64(b64 string, output interface{}) error
DecryptBase64 decrypts base64 string encrypted with EncryptToBase64
func (*SecureBytes) Encrypt ¶
func (sb *SecureBytes) Encrypt(input interface{}) ([]byte, error)
Encrypt encrypts data using AES-192 with authenticated encryption, to avoid additional signing.
https://en.wikipedia.org/wiki/Authenticated_encryption
func (*SecureBytes) EncryptToBase64 ¶
func (sb *SecureBytes) EncryptToBase64(input interface{}) (string, error)
EncryptToBase64 encrypts input and converts to base64 string
func (*SecureBytes) RawDecrypt ¶
func (sb *SecureBytes) RawDecrypt(data []byte) ([]byte, error)
RawDecrypt decrypts data encrypted by RawEncrypt.
func (*SecureBytes) RawDecryptBase64 ¶
func (sb *SecureBytes) RawDecryptBase64(b64 string) ([]byte, error)
RawDecryptBase64 decrypts base64 string encrypted with RawEncryptToBase64
func (*SecureBytes) RawEncrypt ¶
func (sb *SecureBytes) RawEncrypt(data []byte) ([]byte, error)
RawEncrypt can encrypt only bytes, doesn't do serialization
func (*SecureBytes) RawEncryptToBase64 ¶
func (sb *SecureBytes) RawEncryptToBase64(data []byte) (string, error)
RawEncryptToBase64 encrypts bytes and converts to base64 string