mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push * Create codespell.yml * fixup! Format Python code with psf/black push
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
Hill Cipher:
|
||||
The below defined class 'HillCipher' implements the Hill Cipher algorithm.
|
||||
The Hill Cipher is an algorithm that implements modern linear algebra techniques
|
||||
In this algortihm, you have an encryption key matrix. This is what will be used
|
||||
In this algorithm, you have an encryption key matrix. This is what will be used
|
||||
in encoding and decoding your text.
|
||||
|
||||
Algortihm:
|
||||
Algorithm:
|
||||
Let the order of the encryption key be N (as it is a square matrix).
|
||||
Your text is divided into batches of length N and converted to numerical vectors
|
||||
by a simple mapping starting with A=0 and so on.
|
||||
|
||||
The key is then mulitplied with the newly created batch vector to obtain the
|
||||
The key is then multiplied with the newly created batch vector to obtain the
|
||||
encoded vector. After each multiplication modular 36 calculations are performed
|
||||
on the vectors so as to bring the numbers between 0 and 36 and then mapped with
|
||||
their corresponding alphanumerics.
|
||||
|
||||
@@ -6,7 +6,7 @@ BYTE_SIZE = 256
|
||||
|
||||
def main():
|
||||
filename = "encrypted_file.txt"
|
||||
response = input(r"Encrypte\Decrypt [e\d]: ")
|
||||
response = input(r"Encrypt\Decrypt [e\d]: ")
|
||||
|
||||
if response.lower().startswith("e"):
|
||||
mode = "encrypt"
|
||||
|
||||
@@ -42,12 +42,12 @@ def makeKeyFiles(name, keySize):
|
||||
|
||||
publicKey, privateKey = generateKey(keySize)
|
||||
print("\nWriting public key to file %s_pubkey.txt..." % name)
|
||||
with open("%s_pubkey.txt" % name, "w") as fo:
|
||||
fo.write("{},{},{}".format(keySize, publicKey[0], publicKey[1]))
|
||||
with open("%s_pubkey.txt" % name, "w") as out_file:
|
||||
out_file.write("{},{},{}".format(keySize, publicKey[0], publicKey[1]))
|
||||
|
||||
print("Writing private key to file %s_privkey.txt..." % name)
|
||||
with open("%s_privkey.txt" % name, "w") as fo:
|
||||
fo.write("{},{},{}".format(keySize, privateKey[0], privateKey[1]))
|
||||
with open("%s_privkey.txt" % name, "w") as out_file:
|
||||
out_file.write("{},{},{}".format(keySize, privateKey[0], privateKey[1]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user