first commit

This commit is contained in:
ingvar1995 2016-06-21 14:58:11 +03:00
parent 3936f652e9
commit dd53c6a842
21 changed files with 116 additions and 114 deletions

View file

@ -39,6 +39,7 @@ class LibToxEncryptSave(util.Singleton):
libtoxencryptsave = libtox.LibToxEncryptSave()
def __init__(self):
LibToxEncryptSave._instance = self
self._passphrase = None
def set_password(self, passphrase):
@ -50,7 +51,7 @@ class LibToxEncryptSave(util.Singleton):
def is_data_encrypted(self, data):
func = self.libtoxencryptsave.tox_is_data_encrypted
func.restype = c_bool
result = func(c_char_p(data))
result = func(c_char_p(bytes(data)))
return result
def pass_encrypt(self, data):
@ -61,9 +62,9 @@ class LibToxEncryptSave(util.Singleton):
"""
out = create_string_buffer(len(data) + TOX_PASS_ENCRYPTION_EXTRA_LENGTH)
tox_err_encryption = c_int()
self.libtoxencryptsave.tox_pass_encrypt(c_char_p(data),
self.libtoxencryptsave.tox_pass_encrypt(c_char_p(bytes(data)),
c_size_t(len(data)),
c_char_p(self._passphrase),
c_char_p(bytes(self._passphrase)),
c_size_t(len(self._passphrase)),
out,
byref(tox_err_encryption))
@ -86,9 +87,9 @@ class LibToxEncryptSave(util.Singleton):
"""
out = create_string_buffer(len(data) - TOX_PASS_ENCRYPTION_EXTRA_LENGTH)
tox_err_decryption = c_int()
self.libtoxencryptsave.tox_pass_decrypt(c_char_p(data),
self.libtoxencryptsave.tox_pass_decrypt(c_char_p(bytes(data)),
c_size_t(len(data)),
c_char_p(self._passphrase),
c_char_p(bytes(self._passphrase)),
c_size_t(len(self._passphrase)),
out,
byref(tox_err_decryption))