Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import random
  2. import numpy as np
  3. from scikits.audiolab import *
  4. file = open("decoder.dat","a")
  5. def map(x):
  6.     return 3.9*x*(1-x)
  7.  
  8. message_file = Sndfile("chaos_encrypted.wav","r")
  9. message = message_file.read_frames(message_file.nframes)
  10.  
  11. chaos = [random.uniform(0,1)]
  12. i = 0
  13. for x in message:
  14.     chaos.append(map(0.5*(x+chaos[-1])))
  15.     print >>file,'%g %g'%(i,chaos[-1])
  16.     i= i + 1
  17. chaos = np.array(chaos)[0:-1]
  18. restored = (message-chaos)*100
  19.  
  20. format = Format('wav')
  21. restored_file = Sndfile("chaos_decrypted.wav", 'w', format, 1, 44100)
  22. restored_file.write_frames(restored)
  23. file.close()