I combined a VigenereCypher with Sha-1 - I call it... Vigsha!
Hehe... It also uses base64.
I think this encryption makes it practically impossible to retreive a file's contents without the password.
EDIT I put it up on my website. Check it out:
http://jammersbase.ath.cx/vigsha :banana:
Here's the simple code:
from sha import sha
from base64 import encodestring, decodestring
def VigenereCypher(t, k, h=26, o=65):
g = len(k)
return ''.join(chr((ord(k[a%g]) + ord(t[a])) % h + o) for a in range(len(t)))
def SolveCypher(t, k, h=26, o=65):
g = len(k)
return ''.join(chr((ord(t[a]) - ord(k[a%g])) % h + o) for a in range(len(t)))
def EncodeFile(settings):
result = VigenereCypher(encodestring(open(settings['FileIn'], 'r').read()),
sha(settings['Password']).hexdigest(),
settings['Bits'],
settings['Offset'])
file = open(settings['FileOut'], 'w')
file.write(result)
file.close()
def DecodeFile(settings):
result = SolveCypher( open(settings['FileIn'], 'r').read(),
sha(settings['Password']).hexdigest(),
settings['Bits'],
settings['Offset'])
file = open(settings['FileOut'], 'w')
file.write(decodestring(result))
file.close()
if __name__ == '__main__':
settings1 = {
'Password' : 'testing vigsha encryption',
'FileIn' : 'Vigsha.py',
'FileOut' : 'Vigsha_encrypt.py',
'Bits' : 255,
'Offset' : 0
}
settings2 = {
'Password' : 'testing vigsha encryption',
'FileIn' : 'Vigsha_encrypt.py',
'FileOut' : 'Vigsha_solved.py',
'Bits' : 255,
'Offset' : 0
}
EncodeFile(settings1)
DecodeFile(settings2)
Save as 'Vigsha.py' and run to see how it works. For every number you set back the 'bit' variable, you make the encryption stronger, but irreversable. It will error when trying to convert back, because it lost data during the x%h calculation.
I'm sure there are many potential flaws, but as it is currently, it seems to work great.