Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions examples/StringEncryptIsDemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,7 @@
#
myStringEncrypt = StringEncrypt("ABCD-ABCD-ABCD-ABCD")

#
# login to the service
#
result = myStringEncrypt.is_demo()

#
# result[] array holds the information about the license
#
# result["demo"] (boolean) - demo mode flag
# result["label_limit"] (int) - label limit length
# result["string_limit"] (int) - string limit length
# result["bytes_limit"] (int) - bytes/file limit length
# result["credits_left"] (int) - number of credits left
# result["credits_total"] (int) - initial number of credits
# result["cmd_min"] (int) - minimum number of encryption commands
# result["cmd_max"] (int) - maximum number of encryption commands
#
if result:

if result := myStringEncrypt.is_demo():
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 32-50 refactored with the following changes:

This removes the following comments ( why? ):

# login to the service
# result["label_limit"] (int) - label limit length
# result["bytes_limit"] (int) - bytes/file limit length
# result["credits_left"] (int) - number of credits left
# result["cmd_min"] (int) - minimum number of encryption commands
# result["demo"] (boolean) - demo mode flag
# result["credits_total"] (int) - initial number of credits
#
# result["string_limit"] (int) - string limit length
# result[] array holds the information about the license
# result["cmd_max"] (int) - maximum number of encryption commands

print(f'Demo version status - {"True" if result["demo"] else "False"}')

print(f'Label length limit - {result["label_limit"]}')
Expand Down
8 changes: 3 additions & 5 deletions stringencrypt/stringencrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,11 @@ def encrypt_file_contents(self, file_path, label):
:rtype: bool,dict
"""

source_file = open(file_path, 'rb')
bytes = source_file.read()
source_file.close()

with open(file_path, 'rb') as source_file:
bytes = source_file.read()
if not bytes:
return False

Comment on lines -277 to +281
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StringEncrypt.encrypt_file_contents refactored with the following changes:

# additional parameters
params_array = {"command": "encrypt", "bytes": bytes, "label": label}

Expand Down