Whisper Library
|
converts messages and timing intervals back and forth (used by TimingCovertChannel) More...
Public Member Functions | |
MorseCoder (unsigned int delay_short, unsigned int delay_long, unsigned int delay_letter, unsigned int delay_space) | |
Constructor. More... | |
vector< unsigned int > | encodeMessage (string message) |
string | decodeMessage (vector< unsigned int > delays) |
vector< char > | checkString (string message) |
Private Member Functions | |
vector< bool > | encodeLetter (char letter) |
char | decodeLetter (vector< bool > morse_code) |
Private Attributes | |
unsigned int | m_delay_short |
Represents a short signal (in milliseconds) | |
unsigned int | m_delay_long |
Represents a long signal (in milliseconds) | |
unsigned int | m_delay_letter |
Represents a short pause (in milliseconds) | |
unsigned int | m_delay_space |
Represents a long pause (in milliseconds) | |
morse_map | m_morse_map |
Contains the mapping between characters and morse. | |
converts messages and timing intervals back and forth (used by TimingCovertChannel)
MorseCoder converts a message into time intervals using morse and decodes morse back to a message. To do so, call 'encodeMessage' with the message or 'decodeMessage' with time intervals. Use 'checkString' to check if the given message contains characters, that are not supported by morse.
whisper_library::MorseCoder::MorseCoder | ( | unsigned int | delay_short, |
unsigned int | delay_long, | ||
unsigned int | delay_letter, | ||
unsigned int | delay_space | ||
) |
Constructor.
delay_short | is used to encode a short signal (in milliseconds) |
delay_long | is used to encode a long signal (in milliseconds) |
delay_letter | is used to encode the end of a letter (in milliseconds) |
delay_space | is used to encode space between words (in milliseconds) |
vector< char > whisper_library::MorseCoder::checkString | ( | string | message | ) |
Checks the given string for characters, that are not supported by morse. If none were found, the returned vector is empty. Otherwise it contains unsupported characters.
message | the string that is checked |
|
private |
Decodes morse for a single character The passed vector of bool has to contain the encoded letter in which 0 (false) means short and 1 (true) means long.
morse_code | the morse of a single letter |
string whisper_library::MorseCoder::decodeMessage | ( | vector< unsigned int > | delays | ) |
decodeMessage takes a sequence of delays representing morse and converts them back to a message. The delays have to be exactly the ones set in the constructor.
delays | a vector containing delays |
|
private |
Encodes a single character to morse.
letter | the character to decode |
vector< unsigned int > whisper_library::MorseCoder::encodeMessage | ( | string | message | ) |
encodeMessage converts a message into a sequence of delays using morse. Unsupported characters are encoded as '#'.
message | the message as string |