py: added asym en/decryption, fine tuned test script

This commit is contained in:
TLINDEN
2014-12-23 20:13:52 +01:00
parent 87efb36e46
commit b52ac4b0df
3 changed files with 106 additions and 35 deletions

View File

@@ -2,12 +2,12 @@ from pypcp.dll import *
class Stream(object):
def __init__(self, string=None, file=None):
if file:
fd = open(file, 'r')
def __init__(self, backend=None):
if type(backend) is file:
fd = open(backend, 'r')
self._stream = libpcp.ps_new_file(fd)
elif string:
buf = libpcp.buffer_new_buf('inbuf', string, len(string))
elif type(backend) is str:
buf = libpcp.buffer_new_buf('inbuf', backend, len(backend))
self._stream = libpcp.ps_new_inbuffer(buf)
else:
self._stream = libpcp.ps_new_outbuffer()