Serialize your data in binary! Generates unique protocols resistant to decoding
Takes a data structure in JavaScript and generates unique code to serialize and unserialize it. Has high amounts of security to prevent anyone from decoding the protocol. Each generation is unique, so if someone cracked your protocol, you can generate again using this tool. Very useful for security in web applications and IO games.
node index.js
- Edit the data.json file to specify data types. (You can also edit options.json)
- Run
node cli.js
- Generated code located at /out/
require("simpleprotocols")
- Do
npm install simpleprotocols
. - Use it in your code!
var SimpleProtocols = require("simpleprotocols");
var output = SimpleProtocols(dataStruct,options);
int [min] [max]
- Integer/number. Can be decimals. Greatest amount of decimals given is used.int [type]
- Integer/number. Can be:dynamic
,int8
,uint8
,int16
,uint16
,int32
,uint32
,uint24
,float32
string [encoding]
- A string. Encodings include8
(default),16
, and32
.
You can have a fixed array by doing:
[
"length [length]",
"your stuff"
]
You can have dynamic arrays by doing
[
"Your stuff"
]
You can have objects by doing
{
hello: "int 0 255",
this: "string",
is: "string 16",
aobject: "int 0 10000"
}
You can also have conditional statements
{
if: "obj.type == 0",
then: "something",
else: "anotherthing"
}
There are some security features to protect the protocols from being read.
- shuffleObjects - Shuffle order in objects. Default: true
- scrambleConditionals - Scramble conditional statements. Default: true
- scrambleNumbers - Scramble numbers. Default: true
- encodeStrings - Encode strings using rc4 encryption. Default: false
- maskStrings - Masks strings so that they cannot be read easily. Default: true
- maskLength - Sets a mask length. Default: [4,6]
- pack - Pack output code using Dean Edward's packer (http://dean.edwards.name/packer/). Not a significant security feature. Default: false
The json files in this project are not actually json. This is to simplify its syntax. eval()
is used to evaluate the files.