diff --git a/requirements.txt b/requirements.txt
index 3cf6196..e035d5f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,7 +18,7 @@ html5lib==1.0.1
 linecache2==1.0.0
 passlib==1.7.1
 pbr==3.1.1
-pycrypto>=2.6.1
+pycryptodome>=3.6.0
 pyrsistent==0.14.2
 python-mimeparse==1.6.0
 pytz==2018.3
diff --git a/web/pgadmin/utils/crypto.py b/web/pgadmin/utils/crypto.py
index 8350f7a..db8356a 100644
--- a/web/pgadmin/utils/crypto.py
+++ b/web/pgadmin/utils/crypto.py
@@ -29,10 +29,9 @@ def encrypt(plaintext, key):
 
     iv = Random.new().read(AES.block_size)
     cipher = AES.new(pad(key), AES.MODE_CFB, iv)
-    # If user has entered non ascii password (Python2)
-    # we have to encode it first
-    if hasattr(str, 'decode'):
-        plaintext = plaintext.encode('utf-8')
+    # pycrytpodome takes str input only for python version 2.x
+    # This will encode to str for py 2.x and bytes for 3+
+    plaintext = plaintext.encode('utf-8')
     encrypted = base64.b64encode(iv + cipher.encrypt(plaintext))
 
     return encrypted
@@ -65,18 +64,21 @@ def pad(key):
 
     # Key must be maximum 32 bytes long, so take first 32 bytes
     if str_len > 32:
-        return key[:32]
+        # This will encode to str for py 2.x and bytes for 3+
+        return key[:32].encode('utf-8')
 
     # If key size id 16, 24 or 32 bytes then padding not require
     if str_len == 16 or str_len == 24 or str_len == 32:
-        return key
+        # This will encode to str for py 2.x and bytes for 3+
+        return key.encode('utf-8')
 
     # Convert bytes to string (python3)
     if not hasattr(str, 'decode'):
         padding_string = padding_string.decode()
 
     # Add padding to make key 32 bytes long
-    return key + ((32 - str_len % 32) * padding_string)
+    # This will encode to str for py 2.x and bytes for 3+
+    return (key + ((32 - str_len % 32) * padding_string)).encode('utf-8')
 
 
 def pqencryptpassword(password, user):
