mirror of
https://github.com/tcsenpai/xsacks.git
synced 2025-06-06 19:25:38 +00:00
Update README.md
This commit is contained in:
parent
39c70c6386
commit
a99da02dee
109
README.md
109
README.md
@ -8,91 +8,70 @@ Please note that the python implementation is still WiP (actually it works but m
|
||||
You can import the xsacks.py module and use xsacks.cipher(msg, key, securekey) and xsacks.decipher(msg, key, securekey).
|
||||
|
||||
If you modify xsacks.py, you can run a cipher-decipher test directly from the module, so to be sure you didn't screw things up.
|
||||
### X-SACKS Cipher Documentation
|
||||
|
||||
# X-SACK
|
||||
#### Overview
|
||||
|
||||
This cipher is based on crossed substitution of the message and on simple substitution of the key. Let’s explain it with an example.
|
||||
The X-SACKS cipher is a crossed substitution alphabetical cipher that incorporates a secured key for enhanced security. This cipher combines the principles of crossed substitution and simple substitution to encrypt and decrypt messages.
|
||||
|
||||
Our message is: msg = “Attack now”
|
||||
#### Key Generation
|
||||
|
||||
Our key is: key=”secret”
|
||||
- **Randomization**: Generate a random key for each encryption session to ensure maximum security.
|
||||
- **Key Length**: Use a longer key to make it more difficult to crack.
|
||||
|
||||
Our secure-key (you’ll see the meaning later) is: skey=”cryp”
|
||||
#### Encryption and Decryption
|
||||
|
||||
1. **Message Preparation**:
|
||||
- Split the message into individual letters.
|
||||
- Assign a numerical value to each letter based on a chosen alphabet (e.g., ASCII values).
|
||||
|
||||
Before starting, you have to assign to each letter of the alphabet (and also to numbers and symbols if you use them) a number. In a software, it could be the ASCII value of the character. Let’s use a simple one as example, though it’s a valid one.
|
||||
2. **Key Preparation**:
|
||||
- Split the key into two parts.
|
||||
- Assign numerical values to each letter of the key.
|
||||
|
||||
3. **Crossed Substitution**:
|
||||
- Add the first value of the message to the first value of the first part of the key.
|
||||
- Add the second value of the message to the first value of the second part of the key.
|
||||
- Continue this pattern, restarting from the beginning of the key if necessary.
|
||||
|
||||
0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ ? .
|
||||
4. **Reconversion**:
|
||||
- Convert the resulting numerical values back to letters.
|
||||
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
||||
#### Secure Key Encoding
|
||||
|
||||
First of all, you need to split msg separating each letter:
|
||||
1. **Secure Key Preparation**:
|
||||
- Assign numerical values to each letter of the secure key.
|
||||
|
||||
a t t a c k _ n o w
|
||||
2. **Simple Substitution**:
|
||||
- Add the numerical values of the key to the numerical values of the secure key.
|
||||
- Convert the resulting values back to letters.
|
||||
|
||||
NOTE: space is a valid character, so i used “_” just to show it
|
||||
#### Example
|
||||
|
||||
Now substitute to each letter its number:
|
||||
- **Message**: "Attack now"
|
||||
- **Key**: "secret"
|
||||
- **Secure Key**: "cryp"
|
||||
|
||||
10 29 29 11 13 20 36 23 24 32
|
||||
### Usage
|
||||
|
||||
You’ll do the same thing with the key:
|
||||
To use the X-SACKS cipher, follow these steps:
|
||||
|
||||
s e c r e t
|
||||
1. Generate a random key and secure key.
|
||||
2. Prepare the message and keys as described above.
|
||||
3. Perform the crossed substitution and reconversion to encrypt the message.
|
||||
4. Encode the key using the secure key.
|
||||
5. Share the encrypted message and encoded key.
|
||||
|
||||
28 14 12 27 14 29
|
||||
To decrypt the message, the recipient needs the encrypted message, the encoded key, and the secure key.
|
||||
|
||||
### Security Considerations
|
||||
|
||||
Now you have to split the key in two parts:
|
||||
- **Key Security**: Ensure the secure key is kept confidential to prevent unauthorized decryption.
|
||||
- **Key Length**: Use longer keys to increase the difficulty of cracking the cipher.
|
||||
- **Randomization**: Generate random keys for each encryption session to prevent pattern detection.
|
||||
|
||||
### Limitations
|
||||
|
||||
s e c | r e t
|
||||
|
||||
28 14 12 | 27 14 29
|
||||
|
||||
Time to substitute!
|
||||
|
||||
To perform a cross substition, add to the first msg value the first key value of the first group (a+s), then add to the second msg value the first key value of the second group (t+r), continue adding to the third msg value the second key value of the first group, then to the fourth msg value the second key value of the second group and so on.
|
||||
|
||||
|
||||
Restart from the beginning if the key ends.
|
||||
|
||||
Now you should reconvert numbers to letters. If the number exceed the limit of your alphabet, simple start counting from the beginning.
|
||||
|
||||
Let’s decode:
|
||||
|
||||
10 28 15 34 35 21 36 22 20 18
|
||||
|
||||
A S F Y Z L _ M K I
|
||||
|
||||
The encrypted message is: ASFYZL_MKI
|
||||
|
||||
Though is really hard to decode the message without having the key, even having a large amount of text, the last step is to encode also the key, with the secure key.
|
||||
The steps are almost the same, but you don’t have to split the secure key. Simple substitute, check the values and then reconvert.
|
||||
|
||||
S E C R E T
|
||||
|
||||
28 14 12 27 14 29
|
||||
|
||||
C R Y P C R
|
||||
|
||||
12 27 34 25 12 27 40
|
||||
|
||||
So, the encoded key is: 238EQI
|
||||
|
||||
The only way to decrypt the message is having the msg, the encoded key and the secure key, or the plain key if you are so dumb to give the plain one.
|
||||
|
||||
Give to your friend:
|
||||
|
||||
ASFYZL_MKI
|
||||
|
||||
238EQI
|
||||
|
||||
CRYP
|
||||
|
||||
|
||||
|
||||
And he will be able to read “attack now”.
|
||||
|
||||
- **Complexity**: The X-SACKS cipher can be computationally intensive for large messages.
|
||||
- **Key Management**: Managing and securely storing the secure key is crucial for the cipher's effectiveness.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user