Encoding/decoding functions for the Doublespeak protocol.
Navigate to the parent directory in your project where you want the library to reside, and clone it into your project as a submodule.
cd <project name>
git submodule add https://github.com/dblspk/lib.git lib
Thereafter, others who clone your project must do so using the --recursive
option:
git clone --recursive <project URL>
Instantiate the class.
var doublespeak = new Doublespeak([isDebug]);
Param: Boolean
isDebug — Enables debug output to console. Defaults to false
.
Call functions from the class like so:
var encodedStr = doublespeak.encodeText(str);
See the web app for example code.
Param: String
str
Return: String
Remove encoded messages from string.
Param: String
str
Return: String
Encode plaintext to ciphertext.
Param: String
type — MIME type
Param: String
name
Param: Uint8Array
bytes
Return: String
Encode file info and file byte array to ciphertext.
Param: String
str
Return: Object
{ String
cover, Object
dataObjs: [{ Boolean
crcMatch, Number
crc, Number
dataType, Uint8Array
data }]}
Decode encoded messages in string to array of data objects.
dataType determines which "extract..." helper function below should be used to process the data, in conformance with the specification.
Param: Uint8Array
bytes
Return: String
Convert byte array to UTF-8 text.
Param: Uint8Array
bytes
Return: Object
{ Number
type, String
name, String
url, Number
size }
Convert byte array to file components.
The file itself is not returned, only a downloadable link to the file in RAM. Size is in bytes.