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:

  1. string the encrypted block
  2. 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:

  1. string the decrypted block
  2. optional number the amount of bytes added for padding
generated by LDoc 1.4.3 Last updated 2016-03-26 23:19:14