decaflag
v1.0.0
Published
A CLI tool to encode strings into a table and indices.
Downloads
4
Readme
decaflag
A CLI tool that encodes strings into a table and indices format, with the ability to decode them back to the original message. The encoded data is stored in a JSON format and can be decoded back to the original message, which is then output in base64 format.
Installation
# Install globally
npm install -g decaflag
# Or run directly with npx
npx decaflag
Usage
Encoding a message
# Using global installation
decaflag "Hello, World!"
# Using npx
npx decaflag "Hello, World!"
This will create a data.json
file containing the encoded message.
Decoding a message
# Using global installation
decaflag-decode
# Using npx
npx decaflag-decode
# Using npm script (alternative)
npm run decode
This will read the data.json
file and create a flag
file containing the decoded message in base64 format.
How it works
The tool works by creating a table of unique characters from the input string and storing their indices. This creates a simple form of encoding that can be easily reversed.
Data Format
The data.json
file contains two main components:
table
: A string containing all unique characters from the inputindices
: An array of numbers representing positions in the table
Example:
Input:
npx decaflag "hello"
Generated data.json
:
{
"table": "helo\0",
"indices": [0, 1, 2, 3, 3, 4]
}
When decoded, this will reconstruct "hello" and output it in base64 format.
More examples:
Input:
npx decaflag "Hello, World!"
{ "table": "Helo, Wrd!\0", "indices": [0, 1, 2, 2, 3, 4, 5, 6, 3, 7, 2, 8, 9] }
Input:
npx decaflag "AABBCC"
{ "table": "ABC\0", "indices": [0, 0, 1, 1, 2, 2] }
License
MIT License - See LICENSE file for details.