Not an encryption tool
Shift was designed to store non-critical text data in such a way that only keyholders could reconstruct a useful message. Following the cryptography community's rule of "Never roll your own encryption", I am specifically not calling this an encryption tool. I have found that through some basic testing, with a reasonable key, breaking this encoding is not easy for the average teenage 1337 haxxor, but I cannot say anything for it's durability against an experienced code breaker. If you find a way to break this, open up an issue, or contact me via email (any pull requests that can strengthen the tool are welcome too).
If you are looking to encrypt data with shift2, try using a key that is longer than the message. The longer the key, the more secure.
To install this tool and library, use PIP:
# Install shift
pip3 install shift-tool
# Run shift
shift2 -h
NOTE: the executable is named shift2
not shift
.
Shift's commandline tool has two modes:
# Encode
shift2 /path/to/input/file your_key_here > output.shift
# Decode
shift2 -d /path/to/encoded/file your_key_here > output.txt
You can also integrate shift2 into your own program with the library that is automatically installed with the commandline tool.
import shift2.shcrypt as s2c
# Inputs
my_key = "hello_shift"
my_message = "I'm shifty"
# Generate shifted key
key = s2c.key2shifts(my_key)
# Encode the message
data = s2c.encode(my_message, key)
# Print out the encoded message
print(data)
# To decode, just use s2c.decode instead of s2c.encode
By using Python's cProfile
tool, we can see the time required to encode and decode example.txt
. This file contains 50 paragraphs generated by lipsum.com, using the key ewpratten
:
Encoding:
117661 function calls (117578 primitive calls) in 0.065 seconds
Decoding:
151991 function calls (151904 primitive calls) in 0.092 seconds
To run your own speed tests, use the time.sh
script.
The first interesting thing about shift, is that the key can be randomly modified during encoding. This means that the message and key could actually encode eachother (this was done in my first implementation but produced files >1GB from the word "hello")
Binary data must be b64 encoded before being passed through the encoder due to python safety checking unicode data.
To deploy shift to PIP, use:
pip3 uninstall shift-tool
./deploy.sh
pip3 install --no-cache-dir shift-tool
This script must be run with:
python3 -m shift2
NOT
python3 shift2