The Use of Secret (Actual) Code in "Ex Machina"

While there are a number of cinema-code vs real-code comparisons out there in the world to underscore how "action movie hackery" as a plot device is alien to the real thing, here's a clever easter egg from the film Ex Machina shared on reddit:

At one point in the film we see some code on the screen. When I first saw it I was particularly annoyed since it had nothing to do with what the character was doing. But when I got a chance to see it in detail:
#BlueBook code decryption
import sys
def sieve(n):
    x = [1] * n
    x[1] = 0
    for i in range(2,n/2):
            j = 2 * i
            while j < n:
                    x[j]=0
                    j = j+i
    return x

def prime(n,x):
    i = 1
    j = 1
    while j <= n:
            if x[i] == 1:
                    j = j + 1
            i = i + 1
    return i - 1
x=sieve(10000)
code = [1206,301,384,5]
key =[1,1,2,2,]

sys.stdout.write("".join(chr(i) for i in [73,83,66,78,32,61,32]))
for i in range (0,4):
    sys.stdout.write(str(prime(code[i],x)-key[i]))

print
Which when you run with python2.7 you get the following:
ISBN = 9780199226559
Which is Embodiment and the inner life: Cognition and Consciousness in the Space of Possible Minds.

Read more.




Matt Griffin
Matt Griffin

Author



Leave a comment

Comments will be approved before showing up.