Class BFContext
Blowfish main module.
Methods
BFContext:encrypt (block[, setPadding=true[, paddingValue=0]]) | Encrypts a block. |
BFContext:decrypt (block) | Decrypts a block. |
Methods
- BFContext:encrypt (block[, setPadding=true[, paddingValue=0]])
-
Encrypts a block.
Remarks:
-
Blowfish encrypts memory blocks 8 bytes at a time, so we need
to pass an 8-byte aligned memory block and the returned block
will also be aligned to 8 bytes. For that to be achieved, if
the given block's size is not a multiple of 8, it will be
padded. Those bytes can either be ignored (will not be memset'd)
or be set to a value between 0 and 255.
Parameters:
- block string a block of data to encrypt.
- setPadding bool if true, sets the padded bytes to _paddingValue_ (default true)
- paddingValue number the value (between 0 and 255) to set the padding bytes value (default 0)
Returns:
- string the encrypted block
- optional number the amount of bytes used for padding
- BFContext:decrypt (block)
-
Decrypts a block.
Remarks:
-
This function doesn't really expect data to be 8-byte aligned.
It will allocate an 8-byte aligned block and copy encrypted data to that.
It will decrypt that data and then return the block.
Parameters:
- block string block of data do decrypt
Returns:
- string the decrypted block
- optional number the amount of bytes added for padding