Exemplo n.º 1
0
def compare(key, plaintext):  #define Encryption function
    from keygen import keygen  #importing Key Generation module
    from enc import enc  #importing Encryption module
    from ecb_enc import ecb_enc  #importing Encryption module

    for i in range(1, 3):
        enc(key, plaintext,
            '../data/cbc_cipher' + str(i) + '.txt')  #Calling enc function
        ecb_enc(key, plaintext,
                '../data/ecb_cipher' + str(i) + '.txt')  #Calling enc function
Exemplo n.º 2
0
 def encode(self):
  # encode the test episode 
  # create a title, use clips 2,3,4 as source, maybe a credits trailer 
  import enc
  p=enc.enc()
  p.set_options(
    upload_formats=self.upload_formats, 
    rm_temp=False, debug_log=False)
  p.main()
  self.episode = p.episode
  return
Exemplo n.º 3
0
 def encode(self):
     # encode the test episode
     # create a title, use clips 2,3,4 as source, maybe a credits trailer
     import enc
     p = enc.enc()
     p.set_options(upload_formats=self.upload_formats,
                   rm_temp=False,
                   debug_log=False)
     p.main()
     self.episode = p.episode
     return
Exemplo n.º 4
0
def avgruntime(length, key, plaintext,
               ciphertext):  #define Average Run Time for Encryption function
    from keygen import keygen  #Importing keygen module from keygen.py
    from enc import enc  #Importing enc module from enc.py
    import time  #Importing time module
    a = [0] * 5  #Initializing an array of 5 integers
    for i in range(len(a)):  #Iterating the array
        keygen(length, key)  #Calling keygen function
        start = time.time()  #Noting the Start time
        enc(key, plaintext, ciphertext)  #Calling enc function
        end = time.time()  #Noting the end time
        a[i] = end - start  #Calculate the time elapsed for Encryption function
        print('Time Taken = ' + str(a[i]) +
              ' seconds')  #Printing the elapsed time on Command Prompt
    averageRunTime = sum(a) / float(
        len(a))  #Calculating the average time elapsed for Encryption function
    print(
        'Average Run time for lambda=' + length + ' is:' + ' ' +
        str(averageRunTime)
    )  #Printing the length of a Secret Key and time elapsed for Encryption function on Command Prompt
Exemplo n.º 5
0
 def encode(self):
  # encode the test episode 
  # create a title, use clips 2,3,4 as source, maybe a credits trailer 
  # python enc.py -v --client test_client --show test_show --force 
  #  --upload-formats "flv ogv"
  import enc
  p=enc.enc()
  
  p.set_options(force=True, verbose=True, 
    upload_formats=self.upload_formats, 
    rm_temp=False, debug_log=False)
  p.main()
  return
def avgruntime(key, iv, plaintext, ciphertext, result): #define Average Run Time for Encryption function
   from enc import enc #Importing enc module from enc.py
   from dec import dec
   import time #Importing time module
   enc_time = [0]*5 #Initializing an array of 5 integers
   dec_time = [0]*5 #Initializing an array of 5 integers
   for i in range(5): #Iterating the array
      enc_start = time.time() #Noting the Start time
      enc(key, plaintext, ciphertext) #Calling enc function
      enc_end = time.time() #Noting the end time

      dec_start = time.time() #Noting the Start time
      dec(key, iv, ciphertext, result) #Calling enc function
      dec_end = time.time() #Noting the end time
      
      enc_time[i] = enc_start - enc_end #Calculate the time elapsed for Encryption function
      dec_time[i] = dec_start - dec_end #Calculate the time elapsed for Encryption function
      print('Encryption time is '+ str(enc_time[i]) +' and Decryption time is '+ str(dec_time[i]))
      
   averageEncTime = sum(enc_time) / float(len(enc_time)) #Calculating the average time elapsed for Encryption function
   averageDecTime = sum(dec_time) / float(len(dec_time)) #Calculating the average time elapsed for Decryption function
   
   print('Average Run time for Encryption is ' +str(averageEncTime)+'s') #Printing the time elapsed for Encryption function on Command Prompt
   print('Average Run time for Decryption is ' +str(averageDecTime)+'s') #Printing the time elapsed for Decryption function on Command Prompt
Exemplo n.º 7
0
 def counter_thread(self):
     pub = rospy.Publisher("status_encoder",
                           Status_encoder_msg,
                           queue_size=10,
                           latch=True)
     msg = Status_encoder_msg()
     while not rospy.is_shutdown():
         pls = enc.enc()
         self.enc_Az = int(pls[0]) * self.resolution
         self.enc_El = int(pls[1]) * self.resolution + 45 * 3600.
         msg.enc_az = self.enc_Az
         msg.enc_el = self.enc_El
         time.sleep(0.05)
         pub.publish(msg)
         rospy.loginfo('Az :' + str(msg.enc_az / 3600.))
         rospy.loginfo('El :' + str(msg.enc_el / 3600.))
Exemplo n.º 8
0
from enc import enc  #importing Encryption module
from dec import dec  #importing Decryption module
from keygen import keygen  #importing Key Generation module
from freqdist import freqdist  #importing Frequency Distribution module
from avgruntime import avgruntime  #importing Average Run Time for encryption module

if __name__ == '__main__':  #calling main function
    import sys  #importing sys module
    import os  #importing os module
    #First argument i.e sys.argv[0] is always otp.py
    #Second argument i.e sys.argv[1] is the called function
    #Comparing the second command line argument with respective functions to call
    if sys.argv[1] == 'enc':  #Comparing with enc
        enc(sys.argv[2], sys.argv[3], sys.argv[4])  #Calling enc function
    elif sys.argv[1] == 'dec':  #Comparing with dec
        dec(sys.argv[2], sys.argv[3], sys.argv[4])  #Calling dec function
    elif sys.argv[1] == 'keygen':  #Comparing with keygen
        keygen(sys.argv[2], sys.argv[3])  #Calling keygen function
    elif sys.argv[1] == 'freqdist':  #Comparing with freqdist
        freqdist(sys.argv[2], sys.argv[3])  #Calling freqdist function
    elif sys.argv[1] == 'avgruntime':  #Comparing with avgruntime
        avgruntime(sys.argv[2], sys.argv[3], sys.argv[4],
                   sys.argv[5])  #Calling avgruntime function
import enc as sd
print("                               plain text")
print("-" * 80)
data = input()
ct = []
j = []
l = []
for i in range(0, len(data)):
    j.append(ord(data[i]))
#print(j)
for i in range(0, len(j)):
    temp = []
    l = format(j[i], '08b')
    #print(l)
    ct.append(sd.enc(l))
#print(str(ct))
f = open("cipher.txt", "w")
f.write(str(ct))
f.close()
print("                               cipher text")
print("-" * 80)
cip = []
for i in range(0, len(ct)):
    print((chr(int(str(ct[i]), 2))), end=" ")
    k = (chr(int(str(ct[i]), 2)))
    cip.append(k)
print()

cp = str(cip)
cp = cp.replace("[", "")
cp = cp.replace("]", "")
Exemplo n.º 10
0
def encapsulatePacket(data):
    leng = len(data)
    tail = range(1, PACKET_SIZE - leng - SIZE_FIELD_SIZE)
    return enc(leng + data + tail)