Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- #
- # author: @090h
- #
- # #i#<L4w1u0q)mT9Q ----- ????????
- # 1evryyone lies6 ----- 44,~yteU<<*sZOe
- # 1234567 ----- )Wj~5Kb
- # 1234568 ----- *Wj~5Kc
- # 2345678 ----- 1Ym$:Qi
- # abcdef ----- FX=#hP
- # abcdef1 ----- YY>$iQb
- # hackers ----- ]_D1vj_
- # 1337hackers ----- |\o(pS8%j^S
- # hackers1337 ----- UcH5znct)<S
- # task for cryptoanalysis ----- !{p]]E6**ma\ND5vfI72'pe
- # you will never break this cipher! ----- q:11*saOO?&|cWW;/tWDD:$mbbG2$lSGH
- #
- # Flag is MD5(????????)
- def encrypt(input):
- output = ''
- val = 0
- buff = []
- for i in xrange(len(input)):
- val = ord(input[i]) - 32
- if i > 0: val += int(buff[i - 1])
- else: val += len(input) + 13
- if val > 94: val -= 94
- vali = int(val)
- if i == len(input) - 1:
- temp = int(buff[0]) + val
- #print temp
- if temp > 94: temp -= 94
- print('buff[0] %i -> %i'% (int(buff[0]), temp))
- buff[0] = temp
- buff.append(vali)
- print buff
- for i in xrange(len(input)):
- output += (chr(buff[i] + 32))
- return output
- def decrypt(input):
- val = 0
- buff = []
- output = [0 for x in xrange(len(input))]
- for i in xrange(len(input)):
- q = ord(input[i])-32
- buff.append(q)
- print 'BUFF', buff
- for i in range(len(input)-1, 0, -1):
- vali = buff[len(input)-1]
- print 'VAL', vali
- temp = buff[0]
- print "TEMP", temp
- if temp < 94:
- temp += 94
- temp -= vali
- print "TEMP", temp
- print('buff[0] %i -> %i'% (buff[0], temp))
- buff[0] = temp
- break
- print '>>>', buf
- for i in xrange(len(input)):
- val = buff[i]
- if i > 0:
- val -= buff[i - 1]
- else:
- val -= int(len(input) + 13)
- print 'VAL->>>', val + 32
- if val < 0:
- output[i] = val + 94 + 32
- print 'out:', output[1]
- else:
- output[i] = val + 32
- return output
- if __name__ == '__main__':
- res = encrypt('1234567')
- buf = []
- for a in res:
- buf.append(ord(a))
- print buf
- print res
- print '-'*30+'DECRYPT'+'-'*30
- #c = ')Wj~5Kb'
- #c = 'q:11*saOO?&|cWW;/tWDD:$mbbG2$lSGH'
- #c = ']_D1vj_'
- c = '#i#<L4w1u0q)mT9Q'
- buf = decrypt(c)
- print c,'->', buf
- q = ''
- for b in buf:
- q += chr(b)
- print q
Advertisement
Add Comment
Please, Sign In to add comment