Documentation ¶
Index ¶
Constants ¶
const ( // AES128KeySize - Key size (bytes) for AES128 AES128KeySize = 16 // AES192KeySize - Key size (bytes) for AES192 AES192KeySize = 24 // AES256KeySize - Key size (bytes) for AES256 AES256KeySize = 32 )
const ( // DES - Crypt type: software DES DES = iota + 1 // AES128 - Crypt type: software AES128 AES128 // AES192 - Crypt type: software AES192 AES192 // AES256 - Crypt type: software AES256 AES256 )
const (
// DESKeySize - Key size (bytes) for DES
DESKeySize = 8
)
Variables ¶
This section is empty.
Functions ¶
func RandomBytes ¶ added in v0.3.1
RandomBytes generate a random bytes
Types ¶
type AesCrypter ¶
type AesCrypter struct {
// contains filtered or unexported fields
}
AesCrypter implement CoreCrypter interface using AES-128/192/256 depending on the given key length
func NewAesCrypter ¶
func NewAesCrypter(key []byte) *AesCrypter
NewAesCrypter create a new AesCrypter
func (*AesCrypter) Decrypt ¶
func (ac *AesCrypter) Decrypt(dest, src []byte) error
Decrypt decrypt cipher
func (*AesCrypter) DecryptedLen ¶ added in v0.3.1
func (ac *AesCrypter) DecryptedLen(cipherLen int) int
DecryptedLen decrypted info length given cipher with specific length
func (*AesCrypter) Encrypt ¶
func (ac *AesCrypter) Encrypt(dest, src []byte) error
Encrypt encrypt plain It's important to remember that ciphertexts must be authenticated (i.e. by using crypto/hmdc) as well as being encrypted in order to be secure. authentication will be done outside core crypter, (in content encrypter) to include file ID and block No.
func (*AesCrypter) EncryptWithIV ¶
func (ac *AesCrypter) EncryptWithIV(dest, src []byte, iv []byte)
EncryptWithIV encrypt plain using given IV
func (*AesCrypter) EncryptedLen ¶ added in v0.3.1
func (ac *AesCrypter) EncryptedLen(plainLen int) int
EncryptedLen encrypted info length given plain info with specific length
type CoreCrypter ¶
type CoreCrypter interface { // EncryptedLen returns length of encrypted byte stream, given the plain byte stream length EncryptedLen(plainLen int) int // DecrytpedLen returns length of plain byte stream, given the encrypted byte stream length DecryptedLen(cipherLen int) int // Encrypt encrypt src to dest Encrypt(dest, src []byte) error // Decrypt decrypt src to dest Decrypt(dest, src []byte) error }
CoreCrypter defines interface for core crypt module
func NewCoreCrypter ¶
func NewCoreCrypter(mode int, key []byte) CoreCrypter
NewCoreCrypter return a new CoreCrypter
type DesCrypter ¶
type DesCrypter struct {
// contains filtered or unexported fields
}
DesCrypter implement CoreCrypter interfdce
func NewDesCrypter ¶
func NewDesCrypter(key []byte) *DesCrypter
NewDesCrypter create a new DesCrypter
func (*DesCrypter) Decrypt ¶
func (dc *DesCrypter) Decrypt(dest, src []byte) error
Decrypt decrypt cipher
func (*DesCrypter) DecryptedLen ¶ added in v0.3.1
func (dc *DesCrypter) DecryptedLen(cipherLen int) int
DecryptedLen decrypted info length given cipher with specific length
func (*DesCrypter) Encrypt ¶
func (dc *DesCrypter) Encrypt(dest, src []byte) error
Encrypt encrypt plain It's important to remember that ciphertexts must be authenticated (i.e. by using crypto/hmdc) as well as being encrypted in order to be secure. authentication will be done outside core crypter, (in content encrypter) to include file ID and block No.
func (*DesCrypter) EncryptWithIV ¶
func (dc *DesCrypter) EncryptWithIV(dest, src []byte, iv []byte)
EncryptWithIV encrypt plain using given IV
func (*DesCrypter) EncryptedLen ¶ added in v0.3.1
func (dc *DesCrypter) EncryptedLen(plainLen int) int
EncryptedLen encrypted info length given plain info with specific length