YaK:: Discussion #916 Message : 2009-09-27 14.29.13 strick [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
  [Back to discussion: The Yak tries Linux Webcam Video]  
[mega_changes]
[photos]

Discussion #916 Message: 2009-09-27 14.29.13 strick

install pycrypt

$ evince /usr/share/doc/python-crypto/pycrypt.ps.gz

strick@retro:~$ python
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Hash import MD5
>>> m = MD5.new()
>>> m.update('abc')
>>> m.hexdigest()
'900150983cd24fb0d6963f7d28e17f72'
>>> from Crypto.Cipher import AES
>>> from Crypto.Cipher import Blowfish
>>> b=Blowfish.new('passwd', Blowfish.MODE_CBC, 8*'x')
>>> z=b.encrypt('abcdefgh')
>>> b=Blowfish.new('passwd', Blowfish.MODE_CBC, 8*'x')
>>> b.decrypt(z)
'abcdefgh'

>>>from Crypto.PublicKey import RSA
>>> rk=RSA.generate(384,lambda n: open('/dev/urandom').read(n))
>>> rk
<Crypto.PublicKey.RSA.RSAobj_c instance at 0xb76dbfac>
>>>
>>> hash = MD5.new('foo').digest()
>>> hash
'\xac\xbd\x18\xdbL\xc2\xf8\\\xed\xefeO\xcc\xc4\xa4\xd8'
>>> sig = rk.sign(hash, '')
>>> sig
(5635910766727867518384394844488772812542483416326736205994225419700197466916507571003891072480941350727262782912755L,)
>>> rk.verify(hash, sig)
True
>>> rk.verify(hash[:-1], sig)
False
>>>

>>> from Crypto.Cipher import AES
>>> a = AES.new('1234567890123456', AES.MODE_CBC, 'abcdefghijklmnop')
>>> a.encrypt('1234567890123xyz')
"0\xf74\x0cdO\xc5'.\xcf\x0f\x8b\xc6\x86\x03a"


(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2010-03-13)       [Login]
(No back references.)