Skip to content

Commit

Permalink
Added an incorrect password prompt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberbolt committed Mar 31, 2022
1 parent 8ec75c7 commit fdafb5e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
18 changes: 1 addition & 17 deletions cyberdb/data/datas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
'''


import base64
import pickle

from obj_encrypt import Secret
Expand Down Expand Up @@ -57,20 +56,7 @@ def data_to_obj(self, data):

try:
data = self._secret.decrypt(data)
except UnicodeDecodeError:
return {
'code': 2,
'errors-code': errors_code[2]
}

# Check if the dictionary is intact.
if type(data) != type(dict()):
return {
'code': 2,
'errors-code': errors_code[2]
}
elif type(data.get('content')) != type(b'') or not data.get('header') or not \
data.get('header').get('signature'):
except (UnicodeDecodeError, KeyError):
return {
'code': 2,
'errors-code': errors_code[2]
Expand Down Expand Up @@ -130,10 +116,8 @@ def obj_to_data(self, obj):

data['header']['signature'] = self._signature.encrypt(data['content'])
data = self._secret.encrypt(data)
# data = base64.b64encode(data)

else:
# data = base64.b64encode(pickle.dumps(obj))
data = pickle.dumps(obj)

return data
Expand Down
2 changes: 1 addition & 1 deletion cyberdb/network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def read(self) -> dict:

# The client actively disconnects.
if number_of_times == b'':
raise DisconCyberDBError('The TCP connection was disconnected by the other end.')
raise DisconCyberDBError('The TCP connection was disconnected by the other end. It is also possible that the password entered by the client is incorrect.')

r = self._dp.data_to_obj(number_of_times)
if r['code'] != 1:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="CyberDB",
version="0.7.0",
version="0.7.1",
author="Cyberbolt",
author_email="[email protected]",
description="CyberDB is a lightweight Python in-memory database. It is designed to use Python's built-in data structures Dictionaries, Lists for data storage, efficient communication through Socket TCP, and provide data persistence. This module can be used in hard disk database caching, Gunicorn inter-process communication, distributed computing and other fields.",
Expand Down

0 comments on commit fdafb5e

Please sign in to comment.