how encrypt datetime.now with python?

169 views
Skip to first unread message

Asinox

unread,
Jul 30, 2009, 4:33:46 PM7/30/09
to Django users
hi guys, i want to encrypt the "datetime.now()" , im try with base64
but base64 need string... how ill encrypt ?
Thanks :)

Luke Seelenbinder

unread,
Jul 30, 2009, 4:35:19 PM7/30/09
to django...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

convert it to a string: str(datetime.now())

Luke
luke.see...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpyBAIACgkQXQrGVCncjPylkACgmeeVS61T62myd/v+cxIlqxU3
9VkAn0QFoQwGBJFFvzsSO/FOLuFrtVcy
=KS21
-----END PGP SIGNATURE-----

Adam Peacock

unread,
Jul 30, 2009, 4:58:04 PM7/30/09
to Django users
That will work, as long as the parent doesn't need to go back into a
native object easily - if s/he needs to easily get back into a
datetime object, use pickle:

import pickle
import base64

toEncode = pickle.dumps(datetime.now())
encoded = base64.encodestring(toEncode)

decoded = base64.decodestring(encoded)
original = pickle.loads(decoded) #Gives a datetime object back out

On Jul 30, 4:35 pm, Luke Seelenbinder <luke.seelenbin...@gmail.com>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> convert it to a string: str(datetime.now())
>
> Luke
> luke.seelenbin...@gmail.com

Asinox

unread,
Jul 30, 2009, 5:00:59 PM7/30/09
to Django users
Thanks a lot guys :)
Reply all
Reply to author
Forward
0 new messages