t_des.py
来自「It is an experimental testing for python」· Python 代码 · 共 44 行
PY
44 行
from M2Crypto import EVP,Randimport cStringIOdef cipher_filter(cipher,inf,outf): while 1: buf = inf.read() if not buf: break outf.write(cipher.update(buf)) outf.write(cipher.final()) return outf.getvalue()#def test():if __name__=='__main__': f=open('des_data/EFsk.4.bin','rb') key = f.read() f.close() enc=1 dec=0 skip=""" otxt='hello wolrd' k=EVP.Cipher('des_ede_cbc',key,'00000000',enc) #,1,'sha1','saltsalt',5) pbuf=cStringIO.StringIO(otxt) cbuf =cStringIO.StringIO() ctxt = cipher_filter(k,pbuf,cbuf) pbuf.close() cbuf.close()""" f1 = open('des_data/3DESEncrypted.bin','rb') ctxt = f1.read() f1.close() print `ctxt` j = EVP.Cipher('des_ede_cbc',key,'\x00\x00\x00\x00\x00\x00\x00\x00',dec) #,1,'sha1','saltsalt',5) pbuf =cStringIO.StringIO() cbuf =cStringIO.StringIO(ctxt) ptxt = cipher_filter(j, cbuf, pbuf) pbuf.close() cbuf.close() print `ptxt`
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?