Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptBytes(key, ciphertext []byte) (b []byte, err error)
- func DecryptFile(key []byte, filename string) (err error)
- func EncryptBytes(key, b []byte) (ciphertext []byte, err error)
- func EncryptFile(key []byte, filename string) (err error)
- func EncryptKey(pubBytes, key []byte) (ciphertext []byte, err error)
- func GenerateKey(size int) ([]byte, error)
Constants ¶
const ( AES128 = 16 AES192 = 24 AES256 = 32 )
AES key sizes
Variables ¶
var ( ErrCipherTextSize = errors.New("useless/crypto: ciphertext is not a multiple of the block size") ErrKeyBlockSize = errors.New("useless/crypto: key size is not a multiple of the block size") ErrKeySize = errors.New("useless/crypto: Key size should be either 16, 24, or 32") )
Errors
Functions ¶
func DecryptBytes ¶
DecryptBytes will attempt to decrypt the ciphertext using the provided AES key. The ciphertext will be unpadded using the pkcs7 padding scheme.
func DecryptFile ¶
DecryptFile will attempt to copy the contents of the specified file into memory and then decrypt it using the provided key. The orginal file contents is over written with the decrypted bytes in memory.
func EncryptBytes ¶
EncryptBytes will encrypt a byte slice using the provided key. Padding will be added using the pkcs7 padding scheme.
func EncryptFile ¶
EncryptFile will attempt to copy the contents of the specified file into memory and then encrypt it using the provided key. The orginal file contents is over written with the encrypted bytes in memory.
func EncryptKey ¶
EncryptKey can be used to encrypt a AES key with the provided RSA public key. The ciphertext can only be decrypted using the RSA private key of the public key.
func GenerateKey ¶
GenerateKey will attempt to generate a secure aes key of specified size. The aes key can only be 16, 24, or 32 bytes in length.
Types ¶
This section is empty.