Fix backslash issues
This commit is contained in:
parent
f807d323a0
commit
3988604c14
17
main.py
17
main.py
@ -1,5 +1,5 @@
|
||||
import sys
|
||||
|
||||
import platform
|
||||
|
||||
def encode(m):
|
||||
m = bytearray(m, "ascii")
|
||||
@ -52,9 +52,12 @@ def encode(m):
|
||||
|
||||
def decode(n):
|
||||
|
||||
fb = n[-7:-5]
|
||||
sb = n[-2:]
|
||||
msg = n[:-10]
|
||||
if platform.system() == "Windows":
|
||||
n = n.split("\\\\x")
|
||||
else:
|
||||
n = n.split("\\x")
|
||||
|
||||
msg = n[0]
|
||||
message = ""
|
||||
|
||||
for ch in msg:
|
||||
@ -66,12 +69,12 @@ def decode(n):
|
||||
|
||||
message += str(ch)
|
||||
|
||||
fb = bin(int(fb, 16))[2:]
|
||||
fb = bin(int(n[1], 16))[2:]
|
||||
|
||||
while len(fb) < 8:
|
||||
fb = "0" + fb
|
||||
|
||||
sb = bin(int(sb, 16))[2:]
|
||||
sb = bin(int(n[2], 16))[2:]
|
||||
|
||||
while len(sb) < 8:
|
||||
sb = "0" + sb
|
||||
@ -114,7 +117,7 @@ if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Proszę wprowadzić jedną z flag:\n")
|
||||
print(" -e, --encode\tZakoduj <wiadomość>")
|
||||
print(" -d, --decode\tDekoduj <wiadomość_z_ramką>")
|
||||
print(" -d, --decode\tDekoduj <wiadomość_z_ramką>\n")
|
||||
print("Przykład:")
|
||||
print("python main.py -e abc")
|
||||
print("python main.py -d abc\\\\x51\\\\x4a")
|
||||
|
Loading…
Reference in New Issue
Block a user