Polymorphic Quine
This quine prints itself in encrypted form. Every time with a new key for decoding. The cipher is simple - take the character code and add the key to it. Further, the key is increased by one. And so endlessly. Until the numbers run out. :)
Zero patient:
exec(str().join(chr(c) for c in [107, 61, 49, 59, 101, 61, 39, 101, 120, 101, 99, 40, 115, 116, 114, 40, 41, 46, 106, 111, 105, 110, 40, 99, 104, 114, 40, 99, 45, 41, 32, 102, 111, 114, 32, 99, 32, 105, 110, 32, 41, 41, 39, 59, 115, 61, 39, 107, 61, 59, 101, 61, 59, 115, 61, 59, 112, 114, 105, 110, 116, 40, 101, 91, 58, 50, 50, 93, 43, 115, 116, 114, 40, 107, 41, 43, 101, 91, 50, 50, 58, 45, 50, 93, 43, 114, 101, 112, 114, 40, 91, 111, 114, 100, 40, 99, 41, 43, 107, 32, 102, 111, 114, 32, 99, 32, 105, 110, 32, 115, 91, 58, 50, 93, 43, 115, 116, 114, 40, 107, 43, 49, 41, 43, 115, 91, 50, 58, 53, 93, 43, 114, 101, 112, 114, 40, 101, 41, 43, 115, 91, 53, 58, 56, 93, 43, 114, 101, 112, 114, 40, 115, 41, 43, 115, 91, 56, 58, 93, 93, 41, 43, 101, 91, 45, 50, 58, 93, 41, 39, 59, 112, 114, 105, 110, 116, 40, 101, 91, 58, 50, 50, 93, 43, 115, 116, 114, 40, 107, 41, 43, 101, 91, 50, 50, 58, 45, 50, 93, 43, 114, 101, 112, 114, 40, 91, 111, 114, 100, 40, 99, 41, 43, 107, 32, 102, 111, 114, 32, 99, 32, 105, 110, 32, 115, 91, 58, 50, 93, 43, 115, 116, 114, 40, 107, 43, 49, 41, 43, 115, 91, 50, 58, 53, 93, 43, 114, 101, 112, 114, 40, 101, 41, 43, 115, 91, 53, 58, 56, 93, 43, 114, 101, 112, 114, 40, 115, 41, 43, 115, 91, 56, 58, 93, 93, 41, 43, 101, 91, 45, 50, 58, 93, 41]))
It is not difficult to remake it to work with files, and then a funny polymorphic virus can come out.
Development Iterations:
q="'";s='q="";s=;print(s[:3]+q+s[3:7]+q+s+q+s[7:])';print(s[:3]+q+s[3:7]+q+s+q+s[7:])
base quine ( source )
s='s=;print(s[:2]+repr(s)+s[2:])';print(s[:2]+repr(s)+s[2:])
getting rid of a variable
q
exec('s=\'s=;print("exec("+repr(s[:2]+repr(s)+s[2:])+")")\';print("exec("+repr(s[:2]+repr(s)+s[2:])+")")')
using
exec
exec("e='exec()';s='e=;s=;print(e[:-1]+repr(s[:2]+repr(e)+s[2:5]+repr(s)+s[5:])+e[-1:])';print(e[:-1]+repr(s[:2]+repr(e)+s[2:5]+repr(s)+s[5:])+e[-1:])")
unshielded version
e='exec(str().join(chr(c) for c in ))';s='e=;s=;print(e[:-2]+repr([ord(c) for c in s[:2]+repr(e)+s[2:5]+repr(s)+s[5:]])+e[-2:])';print(e[:-2]+repr([ord(c) for c in s[:2]+repr(e)+s[2:5]+repr(s)+s[5:]])+e[-2:])
encryption added
k=0;e='exec(str().join(chr(c-) for c in ))';s='k=;e=;s=;print(e[:22]+str(k)+e[22:-2]+repr([ord(c)+k for c in s[:2]+str(k+1)+s[2:5]+repr(e)+s[5:8]+repr(s)+s[8:]])+e[-2:])';print(e[:22]+str(k)+e[22:-2]+repr([ord(c)+k for c in s[:2]+str(k+1)+s[2:5]+repr(e)+s[5:8]+repr(s)+s[8:]])+e[-2:])
final version with key added
UPD 1
k=0;s='k=;s=;print("exec(str().join(chr(c-"+str(k)+") for c in "+repr([ord(c)+k for c in s[:2]+str(k+1)+s[2:5]+repr(s)+s[5:]])+"))")';print("exec(str().join(chr(c-"+str(k)+") for c in "+repr([ord(c)+k for c in s[:2]+str(k+1)+s[2:5]+repr(s)+s[5:]])+"))")
getting rid of a variable
e
k=0;s='k=;s=;print("exec(str().join(chr(c-"+str(k)+") for c in "+repr([ord(c)+k for c in s[:2]+str(k+1)+s[2:5]+repr(s)+s[5:]])+"))")';exec(s[6:])
shortening the constructor