password given for encrypting data

0

I have done a project in python. Its an Elliptic Curve Cryptography encryption decryption system I used EC ElGamal Algorithm for encryption and decryption. The points on the curve is plotted as shown in the following code:

def prepare_curve_parameters(self):
    len_password = len(self.password)
    self.prime_nums = get_nPrimeNumbers(127 + len_password)

    P = self.prime_nums[-1]
    D = self.prime_nums[len_password]

    password_block = [ord(x) for x in self.password]
    if len_password % 2 != 0:
        password_block.append(len_password)

    print ('password ascii', password_block)

    half_len = len(password_block) / 2
    block1 = password_block[:half_len]
    block2 = password_block[half_len:]
    print('password block 1', block1)
    print('password block 2', block2)

    byte_array1 = array.array('B', block1)
    M = zlib.crc32(byte_array1) & 0xffffffff

    byte_array2 = array.array('B', block2)
    N = zlib.crc32(byte_array2) & 0xffffffff

    print("M={}, N={}".format(M, N))

    A = M % P
    B = N % P

    print("Curve [A={}, B={}, P={}]".format(A, B, P))

    self.a = A
    self.b = B
    self.p = P
    self.d = D

 def get_cryptosystem(self):

    self.prepare_curve_parameters()
    ec = EC(self.a, self.b, self.p)

    rand_perf_square = get_randomPerfSquare(self.p)
    g, _ = ec.at(rand_perf_square)

    print('g', g)

    self.eg = ElGamal(ec, g)

The problem is whenever i gave a password most of the time that password is not working and it shows following error.

Traceback (most recent call last):
  File "CryptoSystem.py", line 144, in <module>
    main()
  File "CryptoSystem.py", line 140, in main
   decrypt(im_file, password, dec_file)
  File "CryptoSystem.py", line 114, in decrypt
    img_str, status = crypto.decrypt(enc_file)
  File "CryptoSystem.py", line 82, in decrypt
   cipher = pickle.load(open(im_file, 'rb'))
  File "/usr/lib/python2.7/pickle.py", line 1384, in load
   return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 864, in load
   dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 897, in load_persid
   self.append(self.persistent_load(pid))
 AttributeError: Unpickler instance has no attribute 'persistent_load'
python
encryption
cryptography
password-encryption
elgamal
asked on Stack Overflow Jul 14, 2018 by Samseela Subair k • edited Jul 14, 2018 by Samseela Subair k

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0