| Server IP : 77.68.64.21 / Your IP : 216.73.216.219 Web Server : Apache System : Linux hp3-wp-1011378.hostingp3.local 3.10.0-1160.144.1.el7.tuxcare.els9.x86_64 #1 SMP Fri Jul 10 17:06:31 UTC 2026 x86_64 User : csh2668128 ( 2112425) PHP Version : 8.1.34 Disable Function : shell_exec,exec,system,popen,set_time_limit MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/m2crypto-0.21.1/demo/ |
Upload File : |
#!/usr/bin/python2.0
"""Demonstrates the use of m2.bio_set_mem_eof_return().
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
from M2Crypto import m2
m2.lib_init()
use_mem = 1
if use_mem:
bio = m2.bio_new(m2.bio_s_mem())
else:
bio = m2.bio_new_file('XXX', 'wb')
ciph = m2.bf_cbc()
filt = m2.bio_new(m2.bio_f_cipher())
m2.bio_set_cipher(filt, ciph, 'key', 'iv', 1)
m2.bio_push(filt, bio)
m2.bio_write(filt, '12345678901234567890')
m2.bio_flush(filt)
m2.bio_pop(filt)
m2.bio_free(filt)
if use_mem:
m2.bio_set_mem_eof_return(bio, 0)
xxx = m2.bio_read(bio, 100)
print `xxx`, len(xxx)
m2.bio_free(bio)
if use_mem:
bio = m2.bio_new(m2.bio_s_mem())
m2.bio_write(bio, xxx)
m2.bio_set_mem_eof_return(bio, 0)
else:
bio = m2.bio_new_file('XXX', 'rb')
ciph = m2.bf_cbc()
filt = m2.bio_new(m2.bio_f_cipher())
m2.bio_set_cipher(filt, ciph, 'key', 'iv', 0)
m2.bio_push(filt, bio)
yyy = m2.bio_read(filt, 100)
print `yyy`
m2.bio_pop(filt)
m2.bio_free(filt)
m2.bio_free(bio)