NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform.
You will still be able to view content, but posting and replying will be temporarily disabled.
To learn more, please review the information in this blog post.

Software Development Kit (SDK) and API Discussions

Python API - NaElement crypt/decrypt child string problem

pilkar
2,523 Views

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

 

 

0 REPLIES 0
Public