mirror of
https://github.com/tcsenpai/xsacks.git
synced 2025-06-04 18:30:25 +00:00
proper refactor as a module: still missing a cleanup of the module itself
This commit is contained in:
parent
090a5fa6df
commit
2fcc71b8c7
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
__pycache__
|
13
main.py
Normal file
13
main.py
Normal file
@ -0,0 +1,13 @@
|
||||
from xsackslib import XSACKS as xsacks
|
||||
|
||||
if __name__ == "__main__":
|
||||
message = "a simple message"
|
||||
key = "casualkeytouse"
|
||||
skey = "evenbetter"
|
||||
cipher = xsacks(key, skey)
|
||||
ciphered = cipher.cipher(message)
|
||||
print(ciphered)
|
||||
print(" ^ Ciphered message and key | Secure key: " + skey)
|
||||
deciphered = cipher.decipher(ciphered[0])
|
||||
print(deciphered)
|
||||
print("^ Deciphered message and key | Secure key: " + skey)
|
@ -1,5 +1,3 @@
|
||||
# How it works
|
||||
|
||||
|
||||
class XSACKS:
|
||||
def __init__(self, key, skey):
|
||||
@ -34,14 +32,14 @@ class XSACKS:
|
||||
|
||||
# Dividing the key in two parts
|
||||
def keyDivider(self):
|
||||
n = int(len(key) / 2)
|
||||
n = int(len(self.key) / 2)
|
||||
partnumber = 0
|
||||
for i in range(0, len(key), n):
|
||||
for i in range(0, len(self.key), n):
|
||||
partnumber += 1
|
||||
if not partnumber > 2:
|
||||
self.keyPARTS.append(key[i : i + n])
|
||||
self.keyPARTS.append(self.key[i : i + n])
|
||||
else:
|
||||
self.keyPARTS[1] = self.keyPARTS[1] + key[i : i + n]
|
||||
self.keyPARTS[1] = self.keyPARTS[1] + self.key[i : i + n]
|
||||
|
||||
# Populating the ascii lists for the key parts
|
||||
def keypartsToAscii(self):
|
||||
@ -49,7 +47,7 @@ class XSACKS:
|
||||
self.keyASCII1.append(ord(char))
|
||||
for char in self.keyPARTS[1]:
|
||||
self.keyASCII2.append(ord(char))
|
||||
for char in key:
|
||||
for char in self.key:
|
||||
self.keyASCII.append(ord(char))
|
||||
|
||||
# Populating the ascii lists for the skey
|
||||
@ -153,7 +151,7 @@ class XSACKS:
|
||||
self.keyDECIPHERChar.append(chr(char))
|
||||
|
||||
# Divide the key deciphered
|
||||
n = int(len(key) / 2)
|
||||
n = int(len(self.key) / 2)
|
||||
partnumber = 0
|
||||
for i in range(0, len(self.keyDECIPHERChar), n):
|
||||
partnumber += 1
|
||||
@ -214,15 +212,3 @@ class XSACKS:
|
||||
|
||||
return messageDECIPHERAsciistr, keyDECIPHERstr
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
message = "a simple message"
|
||||
key = "casualkeytouse"
|
||||
skey = "evenbetter"
|
||||
cipher = XSACKS(key, skey)
|
||||
ciphered = cipher.cipher(message)
|
||||
print(ciphered)
|
||||
print(" ^ Ciphered message and key | Secure key: " + skey)
|
||||
deciphered = cipher.decipher(ciphered[0])
|
||||
print(deciphered)
|
||||
print("^ Deciphered message and key | Secure key: " + skey)
|
Loading…
x
Reference in New Issue
Block a user