Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int x,y,i,j,k,n;
- printf("Enter the size of key matrix: ");
- scanf("%d", &n);
- printf("Enter the key matrix: ");
- int a[n][n];
- for(i=0; i<n; i++){
- for(j=0; j<n; j++){
- scanf("%d", &a[n][n]);
- }
- }
- printf("Enter the message to encrypt: ");
- char s;
- scanf("%c", &s);
- int temp = (n - sizeof(s)%n)%n;
- for(i=0; i<temp; i++){
- s+='x';
- }
- k=0;
- char ans;
- while(k < sizeof(s)){
- for(i=0; i<n; i++){
- int sum = 0;
- int temp[] = {k};
- for(j=0; j<n; j++){
- sum += (a[i][j] % 26 * (s[temp++] - 'a')%26)%26;
- sum = sum % 26;
- }
- ans+=(sum+'a');
- }
- k+=n;
- }
- printf("%c", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement