Documentation ¶
Overview ¶
Package crypto contains encryption-decryption helper functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrShortCiphertext = errors.New("input too short to be valid ciphertext")
ErrShortCiphertext is an error that has text too short.
Functions ¶
func NewCryptoReader ¶
func NewCryptoReader(bm cipher.BlockMode, source io.ReadCloser) io.ReadCloser
func NewCryptoWriter ¶
func NewCryptoWriter(bm cipher.BlockMode, sink io.WriteCloser) io.WriteCloser
NewCryptoWriter returns block cipher writer. from https://github.com/acasajus/dkeyczar/blob/master/streams.go
func Pkcs5unpad ¶
Pkcs5unpad is a stripping function that reverts the PKCS5 method.
Types ¶
type SecretBox ¶
type SecretBox interface { // NewEncryptReader returns EncryptReader from given io.Reader. NewEncryptReader(io.Reader) (io.Reader, error) // NewDecryptReader returns DecryptReader from given io.Reader. NewDecryptReader(src io.Reader) (io.Reader, error) // NewEncryptWriter returns EncryptWriter from given io.Writer. NewEncryptWriter(dst io.Writer) (io.WriteCloser, error) // NewDecryptWriter returns DecryptWriter from given io.Writer. NewDecryptWriter(dst io.Writer) (io.WriteCloser, error) // EncryptedSize returns encrypted data size from given raw data size. EncryptedSize(size uint64) (uint64, error) // DecryptedSize returns decrypted data size from given raw data size. DecryptedSize(size uint64) (uint64, error) }
SecretBox is an encryption and decryption provider.
func NewSecretBox ¶
NewSecretBox returns a SecretBox object with a provided key.
Here is the validation code written for Python:
import os,binascii key=binascii.b2a_base64(os.urandom(32),newline=False) print(key.decode('us-ascii'))
Click to show internal directories.
Click to hide internal directories.