SHARE
TWEET

Untitled

finalshare Mar 17th, 2018 (edited) 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import struct
  2.  
  3. def lcg(m, a, c, x):
  4.     return (a*x + c) % m
  5.  
  6. m = pow(2, 32)
  7. MAXL=15000
  8. list_x=[];
  9. def encrypt():
  10.  
  11.     with open('lcg') as f:
  12.    
  13.    
  14.         a = int(f.readline())
  15.         c = int(f.readline())
  16.         x = int(f.readline())
  17.  
  18.     d = open('nghia.txt').read()
  19.  
  20.     e = ''
  21.     d += '\x00' * (-len(d) % 4)
  22.     d = [d[i:i+4] for i in range(0, len(d), 4)]
  23.    
  24.     e = ''
  25.     for i in range(len(d)):
  26.         e += struct.pack('>I', x ^ struct.unpack('>I', d[i])[0])
  27.    
  28.         print struct.pack('>I', x ^ struct.unpack('>I', d[i])[0])
  29.         x = lcg(m, a, c, x)
  30.        
  31.  
  32.     with open('nghia.enc.txt', 'w') as f:
  33.         f.write(e)
  34.         f.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top