Hello Freedom
This commit is contained in:
68
infidel-code/py_wrappers/python_Connector.py
Normal file
68
infidel-code/py_wrappers/python_Connector.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from ctypes import *
|
||||
import time
|
||||
import _ctypes
|
||||
|
||||
def u_encrypt(message, rec,x):
|
||||
so_file = 'bin/enc_'+x+'.so'
|
||||
u_enc = CDLL(so_file)
|
||||
u_enc.main.restype = c_double
|
||||
c_return = u_enc.main(message.encode('utf-8'), rec.encode('utf-8'))
|
||||
_ctypes.dlclose(u_enc._handle)
|
||||
return c_return
|
||||
|
||||
def u_decrypt(arg,x):
|
||||
so_file2 = 'bin/dec_'+x+'.so'
|
||||
arg_len = len(arg)
|
||||
print("Length ", arg_len)
|
||||
u_dec = CDLL(so_file2)
|
||||
u_dec.main.restype = c_char_p
|
||||
u_dec.main.argtype = c_char_p
|
||||
c_return = u_dec.main(arg)
|
||||
_ctypes.dlclose(u_dec._handle)
|
||||
print("C Return ",c_return)
|
||||
return c_return
|
||||
|
||||
def in_test():
|
||||
|
||||
plain = input("Enter plain text : ")
|
||||
result = u_encrypt(plain)
|
||||
|
||||
# u_decrypt()
|
||||
print(result)
|
||||
|
||||
def rapid_enc(x):
|
||||
print("input len : %d" % len(plain))
|
||||
u_encrypt(plain, x)
|
||||
|
||||
def rapid_dec(x):
|
||||
u_decrypt(x)
|
||||
|
||||
def file_handler(f_name, num, std):
|
||||
num = str(num).zfill(2)
|
||||
f = open(".cipher/ees"+std+"/"+f_name+"_"+num+".dat", "rb")
|
||||
cipher = f.read()
|
||||
print("Python log : cipher len ",len(cipher))
|
||||
return cipher
|
||||
|
||||
# print("C decrypt time : ", u_decrypt())
|
||||
# print("C Enc : ", u_encrypt("ADADADADA"))
|
||||
|
||||
def dec_test(std, rpt):
|
||||
for i in range(rpt):
|
||||
recs = str(i).zfill(3)
|
||||
# rapid_enc(recs)
|
||||
args = file_handler("cipher", recs, std)
|
||||
u_decrypt(args, std)
|
||||
print("-"*100)
|
||||
|
||||
def enc_test(std, rpt):
|
||||
for i in range(rpt):
|
||||
recs = str(i).zfill(3)
|
||||
plain = "This is Legit "+recs+" "+std
|
||||
u_encrypt(plain, recs, std)
|
||||
print("-"*100)
|
||||
|
||||
def enc_dec_test(x, rpt):
|
||||
enc_test(x, rpt)
|
||||
dec_test(x, rpt)
|
||||
|
||||
Reference in New Issue
Block a user