ENCRYPT()
Encrypts data using a symmetric cipher
VARBINARY
or BLOB
ENCRYPT ( input USING <algorithm> [MODE <mode>] KEY key [IV iv] [<ctr_type>] [CTR_LENGTH ctr_length] [COUNTER initial_counter] ) <algorithm> ::= <block_cipher> | <stream_cipher> <block_cipher> ::= AES | ANUBIS | BLOWFISH | KHAZAD | RC5 | RC6 | SAFER+ | TWOFISH | XTEA <stream_cipher> ::= CHACHA20 | RC4 | SOBER128 <mode> ::= CBC | CFB | CTR | ECB | OFB <ctr_type> ::= CTR_BIG_ENDIAN | CTR_LITTLE_ENDIAN
Parameter | Description |
---|---|
input |
Input to encrypt as a blob or (binary) string |
algorithm |
The algorithm to use for decryption |
mode |
The algorithm mode;only for block ciphers |
key |
The encryption/decryption key |
iv |
Initialization vector or nonce;should be specified for block ciphers in all modes except |
ctr_type |
Endianness of the counter;only for |
ctr_length |
Counter length;only for |
initial_counter |
Initial counter value;only for |
Note
|
|
Algorithm | Key size (bytes) | Block size (bytes) | Notes |
---|---|---|---|
Block Ciphers |
|||
|
16, 24, 32 |
16 |
Key size determines the AES variant: |
|
16 - 40, in steps of 4 (4x) |
16 |
|
|
8 - 56 |
8 |
|
|
16 |
8 |
|
|
8 - 128 |
8 |
|
|
8 - 128 |
16 |
|
|
16, 24, 32 |
16 |
|
|
16, 24, 32 |
16 |
|
|
16 |
8 |
|
Stream Ciphers |
|||
|
16, 32 |
1 |
Nonce size (IV) is 8 or 12 bytes.For nonce size 8, initial_counter is a 64-bit integer, for size 12, 32-bit. |
|
5 - 256 |
1 |
|
|
4x |
1 |
Nonce size (IV) is 4y bytes, the length is independent of key size. |