Skip to content

Commit

Permalink
Merge pull request #1791 from Kumar-laxmi/dev
Browse files Browse the repository at this point in the history
Hill Cipher in C Added
  • Loading branch information
Kumar-laxmi authored Oct 6, 2023
2 parents a1d4ee2 + 6a4f506 commit f10972e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions C/Cryptography/Hill_Cipher.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include<stdio.h>
#include<string.h>
int main() {
unsigned int a[3][3] = { { 6, 24, 1 }, { 13, 16, 10 }, { 20, 17, 15 } };
unsigned int b[3][3] = { { 8, 5, 10 }, { 21, 8, 21 }, { 21, 12, 8 } };
int i, j;
unsigned int c[20], d[20];
char msg[20];
int determinant = 0, t = 0;
;
printf("Enter plain text\n ");
scanf("%s", msg);
for (i = 0; i < 3; i++) {
c[i] = msg[i] - 65;
printf("%d ", c[i]);
}
for (i = 0; i < 3; i++) {
t = 0;
for (j = 0; j < 3; j++) {
t = t + (a[i][j] * c[j]);
}
d[i] = t % 26;
}
printf("\nEncrypted Cipher Text :");
for (i = 0; i < 3; i++)
printf(" %c", d[i] + 65);
for (i = 0; i < 3; i++) {
t = 0;
for (j = 0; j < 3; j++) {
t = t + (b[i][j] * d[j]);
}
c[i] = t % 26;
}
printf("\nDecrypted Cipher Text :");
for (i = 0; i < 3; i++)
printf(" %c", c[i] + 65);
return 0;
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
| 3. | Columnar Transposition Cipher | [C](https://github.com/Kumar-laxmi/Algorithms/blob/main/C/Cryptography/ColumnarTranspositionCipher.c), [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/ColumnarTranspositionCipher.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/ColumnarTranspositionCipher.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/ColumnarTranspositionCipher.py) |
| 4. | Diffie - Hellman Algorithm | [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/DiffieHellman.py) |
| 5. | Elgamal Cryptosystem | [C](https://github.com/Kumar-laxmi/Algorithms/blob/main/C/Cryptography/Elgamal.c), [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/Elgamal.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/Elgamal.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/Elgamal.py) |
| 6. | Hill Cipher | [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/HillCipher.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/HillCipher.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/HillCipher.py) |
| 6. | Hill Cipher | [C](https://github.com/Kumar-laxmi/Algorithms/blob/main/C/Cryptography/Hill_Cipher.c), [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/HillCipher.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/HillCipher.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/HillCipher.py) |
| 7. | Homophonic Substitution | [C](https://github.com/Kumar-laxmi/Algorithms/blob/main/C/Cryptography/homophonic_substitution.c), [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/homophonic_substitution.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/HomophonicSubstitution.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/homophonic_Substitution.py) |
| 8. | Morse Code | [C](https://github.com/Kumar-laxmi/Algorithms/blob/main/C/Cryptography/MorseCodeConvortor.c), [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/MorseCodeConvotor.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/MorseCodeConverter.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/MorseCodeConvortor.py) |
| 9. | Playfair Cipher | [C](https://github.com/Kumar-laxmi/Algorithms/blob/main/C/Cryptography/playfair_cipher.c), [C++](https://github.com/Kumar-laxmi/Algorithms/blob/main/C%2B%2B/Cryptography/playfair_cipher.cpp), [Java](https://github.com/Kumar-laxmi/Algorithms/blob/main/Java/Cryptography/PlayfairCipher.java), [Python](https://github.com/Kumar-laxmi/Algorithms/blob/main/Python/Cryptography/playfair_cipher.py) |
Expand Down

0 comments on commit f10972e

Please sign in to comment.