encryption with python
ncf
nothingcanfulfill at gmail.com
Wed Sep 7 15:06:16 EDT 2005
Steve M wrote:
> >My goal is to combine two different numbers and
> encrypt them to create a new number that cann't be traced back to the
> originals.
>
> Here's one:
> def encrypt(x, y):
> """Return a number that combines x and y but cannot be traced back
> to them."""
> return x + y
Or you can use sha1 so you can't do basic checks to find out. :)
It seems to me like he's trying to do some DH like thing, so yea, he
might rather a hash
**** UNTESTED ****
import sha1
def encrypt(x,y):
''' Return a number that combines x and y but cannot be traced back
to them. Number returned is in xrange(2**24). '''
def _dosha(v): return sha1.new(str(v)).hexdigest()
return int(_dosha(_dosha(x)+_dosha(y))[5:11],16)
More information about the Python-list
mailing list