Subscribe

Python API - NaElement crypt/decrypt child string problem

[ Edited ]

Hi,

I would like to ask for an advice, why I'm getting an error when using methods child_add_string_enc() in NaElement object in python (v.2.6.6. Oracle Linux 6.7):

 Traceback (most recent call last):
  File "crypt_test.py", line 7, in <module>
    x.child_add_string_encrypted("crypt-pwd", passwd)
  File "NaElement.py", line 270, in child_add_string_encrypted
    encrypted_value = self.RC4(key,value)
  File "NaElement.py", line 365, in RC4
    box = self.prepare_key(key)
  File "NaElement.py", line 402, in prepare_key
    k = unpack('C*',key)
struct.error: bad char in struct format

 

ok then, I have added "import struct" in the NaElement.py file, then got this error:

Traceback (most recent call last):
  File "crypt_test.py", line 8, in <module>
    x.child_add_string_encrypted("crypt-pwd", passwd)
  File "NaElement.py", line 270, in child_add_string_encrypted
    encrypted_value = self.RC4(key,value)
  File "NaElement.py", line 365, in RC4
    box = self.prepare_key(key)
  File "NaElement.py", line 402, in prepare_key
    k = unpack('C*',key)
struct.error: bad char in struct format

 

Here is my test python code:

from NaElement import *
import struct
passwd = "Test-string-to-encrypt"
x = NaElement("test")
x.child_add(NaElement("plain-pwd", passwd))
x.child_add_string_encrypted("crypt-pwd", passwd)

 

What is the problem? Python v.2.6.6 should be supported, do I need any special packages to install? Quite the same code in Perl (using perl APIs with pack/unpack functions) works withould problems...

 

Thanks for any help in advance.

Rostislav