Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Reverse iterate
- def revpow2(z, c, b):
- if b == 1:
- return -((z-c)**(0.5));
- else:
- return (z-c)**(0.5);
- # Forward iterate
- def fowpow2(z, c):
- return z * z + c;
- # Encrypts a byte
- def encrypt_byte(z, c, pt):
- for b in pt:
- z=revpow2(z,c,int(b));
- print(z);
- return z;
- # Decrypts a byte
- def decrypt_byte(z, c):
- s = ""
- for b in range(8):
- print(z);
- s += "0" if z.real > 0 else "1";
- z=fowpow2(z,c);
- s = s[::-1]; # reverse the bits
- return s;
- # The secret key (c), and origin point (z)
- c = (-.75+.09j);
- z = (0+0j);
- pt0 = "01000001";
- print("Encrypt: " + pt0);
- print("______________________________________");
- ct = encrypt_byte(z, c, pt0);
- print("______________________________________");
- print("");
- print("Decrypt");
- print("______________________________________");
- pt1 = decrypt_byte(ct, c);
- print("______________________________________");
- print("");
- print("decrypted: " + pt1);
Advertisement
Add Comment
Please, Sign In to add comment