BaltCTF 2013 Crypto 100

this task is described as below:

USS ENTERPRISE [100]  
crypto  
Hello we intercepted strange message. Decode it.  
pySpIl. wmqDp oDl! nQSamn lIjngychoIl tDt nDn'Do  
Hint. They use primitive cryptosystem.  

after some time we get hint:”Veni, Vidi, Vici”

USS ENTERPRISE should be star trek.

so it should be ‘klingon encrypted with cesars cipher’

we work this out after the ctf:

here is the code:

key1='a','b','ch','D','e','gh','H','I','j','l','m','n','ng','o','p','q','Q','r','S','t','tlh','u','v','w','y','\'','0','1','2','3','4','5','6','7','8','9','0'
key='a','b','ch','D','e','gh','H','I','j','l','m','n','ng','o','p','q','Q','r','S','t','tlh','u','v','w','y','\''
aa='pySpIl. wmqDp oDl! nQSamn lIjngychoIl tDt nDn\'Do'
offset=0
result=''


def returnindex(aa):
    index=-1
    for z in range(len(key)):
     if len(aa)==len(key[z]):
         if(aa[:1]==key[z][:1]):
               if(aa[1:]==key[z][1:]):
                   index=z
return index

for offset in range(26):
    result1=''
    for i in range(len(aa)):
     tmp=returnindex(aa[i])
     if(tmp!=-1):
      result1+=key[(tmp-offset)%26]
     else:
      result1+=aa[i]
    print result1

print "we use offset:3"
time.sleep(1000)

got this:nuqneH. tlhIngan maH! joqwIj HeghjguchmeH QaQ jajvam

translate it to english can get the key.