gs gs122 Cryptography - Polyalphabetic Cipher - Quiz No.1
gs gs122 Data Communication and Computer Network Quiz
This quiz belongs to book/course code gs gs122 Data Communication and Computer Network of gs organization. We have 268 quizzes available related to the book/course Data Communication and Computer Network. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Cryptography. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
void Cipher(string msg, string key) { // Get key matrix from the key string int keyMat[3][3]; getKeyMatrix(key, keyMat); int msgVector[3][1]; for (int i = 0; i <=2; i++) msgVector[i][0] = (msg[i]) % 65; int cipherMat[3][1]; // Following function generates // the encrypted vector encrypt(cipherMat, keyMat, msgVector); string CipherText; for (int i = 0; i <=2; i++) CipherText += cipherMat[i][0] + 65; cout << CipherText; }
public class Cipher { public static String encrypt(String text, final String key) { String res = ""; text = text.toUpperCase(); for (int i = 0, j = 0; i < text.length(); i++) { char c = text.charAt(i); if (c < 'A' || c > 'Z') continue; res += (char) ((c + key.charAt(j) - 2 * 'A') % 26 + 'A'); j = ++j % key.length(); } return res; }