Nis Code
Nis Code
4.1 answer
#include <bits/stdc++.h>
#include <iostream>
// Initializing cipherText
string cipherText = "";
// Method 2
// Returning plain text
static string stringDecryption(string s, string key)
{
// Initializing plain text
string plainText = "";
// Initializing integer array of key length
// which stores difference
// of corresponding no.'s of
// each character of cipherText and key
int plain[key.length()];
// Returning plainText
return plainText;
}
// Method 3
// Main driver method
int main()
{
// Declaring plain text
string plainText = "Hello";
// Declaring key
string key = "MONEY";
return 0;
}
Page 43
4.1 answer
return result;
}
row = 0, col = 0;
for (int i=0; i< cipher.length(); i++)
{
// check the direction of flow
if (row == 0)
dir_down = true;
if (row == key-1)
dir_down = false;
return 0;
}
Page 46
4.1 answer
#include<bits/stdc++.h>
using namespace std;
// Key for Columnar Transposition
string const key = "HACK";
map<int,int> keyMap;
void setPermutationOrder()
{
// Add the permutation order into map
for(int i=0; i < key.length(); i++)
{
keyMap[key[i]] = i;
}
}
// Encryption
string encryptMessage(string msg)
{
int row,col,j;
string cipher = "";
if (msg.length() % col)
row += 1;
char matrix[row][col];
return cipher;
}
// Decryption
string decryptMessage(string cipher)
{
/* calculate row and column for cipher Matrix */
int col = key.length();
// Driver Program
int main(void)
{
/* message */
string msg = "Geeks for Geeks";
setPermutationOrder();