mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Update linear_discriminant_analysis.py and rsa_cipher.py (#8680)
* Update rsa_cipher.py by replacing %s with {} * Update rsa_cipher.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update linear_discriminant_analysis.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update linear_discriminant_analysis.py * Update linear_discriminant_analysis.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update linear_discriminant_analysis.py * Update linear_discriminant_analysis.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update linear_discriminant_analysis.py * Update machine_learning/linear_discriminant_analysis.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update linear_discriminant_analysis.py * updated --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
11582943a5
commit
bf30b18192
@ -76,10 +76,11 @@ def encrypt_and_write_to_file(
|
|||||||
key_size, n, e = read_key_file(key_filename)
|
key_size, n, e = read_key_file(key_filename)
|
||||||
if key_size < block_size * 8:
|
if key_size < block_size * 8:
|
||||||
sys.exit(
|
sys.exit(
|
||||||
"ERROR: Block size is %s bits and key size is %s bits. The RSA cipher "
|
"ERROR: Block size is {} bits and key size is {} bits. The RSA cipher "
|
||||||
"requires the block size to be equal to or greater than the key size. "
|
"requires the block size to be equal to or greater than the key size. "
|
||||||
"Either decrease the block size or use different keys."
|
"Either decrease the block size or use different keys.".format(
|
||||||
% (block_size * 8, key_size)
|
block_size * 8, key_size
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
encrypted_blocks = [str(i) for i in encrypt_message(message, (n, e), block_size)]
|
encrypted_blocks = [str(i) for i in encrypt_message(message, (n, e), block_size)]
|
||||||
@ -101,10 +102,11 @@ def read_from_file_and_decrypt(message_filename: str, key_filename: str) -> str:
|
|||||||
|
|
||||||
if key_size < block_size * 8:
|
if key_size < block_size * 8:
|
||||||
sys.exit(
|
sys.exit(
|
||||||
"ERROR: Block size is %s bits and key size is %s bits. The RSA cipher "
|
"ERROR: Block size is {} bits and key size is {} bits. The RSA cipher "
|
||||||
"requires the block size to be equal to or greater than the key size. "
|
"requires the block size to be equal to or greater than the key size. "
|
||||||
"Did you specify the correct key file and encrypted file?"
|
"Did you specify the correct key file and encrypted file?".format(
|
||||||
% (block_size * 8, key_size)
|
block_size * 8, key_size
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
encrypted_blocks = []
|
encrypted_blocks = []
|
||||||
|
@ -399,7 +399,7 @@ def main():
|
|||||||
if input("Press any key to restart or 'q' for quit: ").strip().lower() == "q":
|
if input("Press any key to restart or 'q' for quit: ").strip().lower() == "q":
|
||||||
print("\n" + "GoodBye!".center(100, "-") + "\n")
|
print("\n" + "GoodBye!".center(100, "-") + "\n")
|
||||||
break
|
break
|
||||||
system("cls" if name == "nt" else "clear")
|
system("clear" if name == "posix" else "cls") # noqa: S605
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user