I have a script I wrote in Python2 to encrypt files using Crypto.Cipher.ARC4
Now that Python2 is EOL for over a year now, I've been starting to move everything to Python3.
Is it possible to decrypt files encrypted with my script using Python3 (and vice versa)?
Here is my script:
#!/usr/bin/python
import os
from Crypto.Cipher import ARC4
key = "my_redacted_string"
dir = os.path.realpath(__file__)
dir = os.path.dirname(dir)
# https://stackoverflow.com/questions/4934806
files = os.listdir(dir)
os.chdir(dir)
script_name = __file__
script_name = script_name.split("/")[-1]
proceed = [1, "y", "yes",'1']
for f in files:
if f == script_name:
pass
else:
string = "Process file? : %s > " % f
answer = raw_input(string)
if answer in proceed:
filo = open(f) # filo == file object, file open
data = filo.read()
filo.close()
e = ARC4.new(key)
e = e.encrypt(data)
out_name = "%s.dat" % f
filo = open(out_name, 'w')
filo.write(e)
filo.close()
Here is a script I wrote to decrypt files encrypted with the above script:
#!/usr/bin/python
import os
from Crypto.Cipher import ARC4
key = "my_redacted_string"
dir = os.path.realpath(__file__)
dir = os.path.dirname(dir)
# https://stackoverflow.com/questions/4934806
files = os.listdir(dir)
os.chdir(dir)
script_name = __file__
script_name = script_name.split("/")[-1]
proceed = [1, "y", "yes",'1']
for f in files:
if f == script_name:
pass
else:
string = "Process file? : %s > " % f
answer = raw_input(string)
if answer in proceed:
filo = open(f) # filo == file object, file open
data = filo.read()
filo.close()
d = ARC4.new(key)
d = d.decrypt(data)
out_name = os.path.splitext(f)[0]
print out_name
filo = open(out_name, 'w')
filo.write(d)
filo.close()
I try to make everything cross-platform and incuded #!/usr/bin/python
as a habit, but I am using 64-bit Windows 10 on my laptop (I have one Linux box, VMs, and VPSes using Linux and using this script client side so using Windows)