-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
082a375
commit 6a4f506
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters