Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to signing files in naruno/lib/sign.py #1743

Open
onuratakan opened this issue Aug 8, 2023 · 1 comment
Open

Adding ability to signing files in naruno/lib/sign.py #1743

onuratakan opened this issue Aug 8, 2023 · 1 comment

Comments

@onuratakan
Copy link
Member

Create is_file parameter in sign() function and if this parameter equals to 'True' open the data as file and read the file content. @autopilot

@codeautopilot
Copy link

codeautopilot bot commented Aug 8, 2023

To solve this task, you need to modify the sign() function in the naruno/lib/sign.py file.

Here is a step-by-step guide on how to do it:

  1. Add an additional parameter is_file to the sign() function. The function definition should look like this: def sign(data: str, password: str, is_file: bool = False) -> str:. The is_file parameter is optional and defaults to False.

  2. Inside the sign() function, check if is_file is True. If it is, open the data as a file and read its content. Replace the data variable with the content of the file. You can use the built-in open() function to open the file and the read() method to read its content. Here is a code snippet that does this:

if is_file:
    with open(data, 'r') as file:
        data = file.read()
  1. The rest of the function should remain the same. It will sign the data (which is now the content of the file if is_file is True) using the user's private key.

Remember to handle exceptions properly. For instance, if the file specified in data does not exist, the open() function will raise a FileNotFoundError. You should catch this exception and handle it appropriately.


Current plan usage: 29.89%


Have feedback or need help?
Send me an email to [email protected]
Join us on Discord

@github-actions github-actions bot added the Lib label Aug 8, 2023
@onuratakan onuratakan added AutoPR and removed AutoPR labels Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant