/usr/share/pyshared/Codeville/crypt.py is in codeville 0.8.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Written by Ross Cohen
# see LICENSE.txt for license information
from entropy import string_to_long, long_to_string
import hashlib
def crypt(text, key, counter=0L):
keylen, length = len(key), len(text)
pos, cyphertext = 0, []
while pos < length:
scounter = long_to_string(counter, keylen)
hash = hashlib.sha1("ctr mode crypt" + key + scounter).digest()
for i in xrange(min(length-pos, len(hash))):
cyphertext.append(chr(ord(hash[i]) ^ ord(text[pos])))
pos += 1
counter += 1
return (''.join(cyphertext), counter)
|