new Twofish(data)
Creates a new Twofish instance
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Initialization options for the class, passed automatically into Twofish#initialize |
- Copyright:
- Copyright (c) 2013, Jeff Lyon.
- License:
- Source:
Extends
Requires
- module:convert
Members
-
debug_mode :Boolean
-
Controls whether to log debug output to the console.
Type:
- Boolean
- Default Value:
- false
- Source:
- See:
-
s_box
-
Key-dependent substitution box (generated by Twofish#expand_key
- Source:
Methods
-
debug_write(arguments)
-
Writes debug information to the console if BlockCipher#debug_mode is turned on.
Parameters:
Name Type Argument Description arguments
mixed <repeatable>
The variables to write to console - Inherited From:
- Source:
-
decrypt(ciphertext) → {String}
-
Decrypts a string.
Parameters:
Name Type Description ciphertext
String An ASCII string to decrypt. - Inherited From:
- Source:
Returns:
Encrypted data- Type
- String
-
encrypt(plaintext) → {String}
-
Encrypts a string using the padding and block cipher mode of operation specificed on initialization.
Parameters:
Name Type Description plaintext
String An ASCII string to encrypt. Can be binary or plaintext. For plaintext, be sure to use convert.utf8.encode to encode any UTF characters. - Inherited From:
- Source:
Returns:
Decrypted data- Type
- String
-
get_block_size() → {Number}
-
Getter function for the block size
- Source:
Returns:
The block size (in bits)- Type
- Number
-
get_key() → {Array}
-
Getter function for the key
- Source:
Returns:
The byte array for the key- Type
- Array
-
get_key_length() → {Number}
-
Getter function for the key length
- Source:
Returns:
The key length (in bits)- Type
- Number
-
get_salt() → {String}
-
Gets the salt used for any passphrase-based key derivation.
- Inherited From:
- Source:
Returns:
- Type
- String
-
initialize(data) → {Twofish}
-
Called automatically on class instantiation. Invokes BlockCipher#initialize before handling class-specific functionality.
Parameters:
Name Type Description data
Object See BlockCipher#initialize for a list of supported properties. - Source:
Returns:
- Type
- Twofish
-
reverse_word()
-
Reverses the endianness of a word's byte order
- Source:
-
set_key(key) → {Twofish}
-
Set the key, either from a string or an array of byte values
Parameters:
Name Type Description key
string | Array The symmetric key. Must be ASCII-encoded binary string or Array. - Source:
Returns:
This Twofish instance (chainable)- Type
- Twofish
-
test() → {boolean}
-
Sanity test for the class. NOTE: You must initialize the instance with data.block_mode set to ECB and data.pad_mode set to ZeroPadding for this to work! See BlockCipher#initialize for more information on initialization properties.
- Source:
Returns:
- Type
- boolean