Professional Documents
Culture Documents
This research aims to introduce a novel Vigenere encryption and decryption technique. A
basic polyalphabetic substitution technique is used in the Vigenere cipher to encrypt
alphabetic text. The technique is more secure than a typical Caesar cipher since it employs
a keyword to change the characters in the plaintext.
3.2 Pseudocode:
Start of Program
Vigenere Encryption
Write
Ciphered Text
Vigenere Decryption
Write
Deciphered
4. Your Code with Comments and Explanation
#include <iostream>
End
#include <fstream>
#include <string>
using namespace std;
// Initialize variables
string ciphertext = "";
int keyLength = key.length();
int textLength = plaintext.length();
// Encryption loop
for (int i = 0; i < textLength; ++i) {
char currentChar = plaintext[i];
// Perform encryption
char encryptedChar = static_cast<char>((currentChar - base + (key[i % keyLength] -
shiftBase)) % 26 + base);
ciphertext += encryptedChar;
} else {
ciphertext += currentChar; // Keep non-alphabetical characters unchanged
}
}
return ciphertext;
}
// Initialize variables
string plaintext = "";
int keyLength = key.length();
int textLength = ciphertext.length();
// Decryption loop
for (int i = 0; i < textLength; ++i) {
char currentChar = ciphertext[i];
// Perform decryption
char decryptedChar = static_cast<char>((currentChar - base - (key[i % keyLength] -
shiftBase) + 26) % 26 + base);
plaintext += decryptedChar;
} else {
plaintext += currentChar; // Keep non-alphabetical characters unchanged
}
}
return plaintext;
}
int main() {
// Read plaintext from file
ifstream inFile("plaintext.txt");
// Close files
inFile.close();
cipherFile.close();
cout << "Ciphering successful!" << endl;
} else {
cout << "Unable to open files for ciphering!" << endl;
}
// Close files
cipherInFile.close();
decipherFile.close();
cout << "Deciphering successful!" << endl;
} else {
cout << "Unable to open files for deciphering!" << endl;
}
return 0;
-The genereEncryptDynamic function uses dynamic key expansion to carry out Vigenere
encryption. It uses the generateDynamicKey function to create a dynamic key, encrypts the
plaintext, and receives the keyword as inputs.
-The Vigenere decryption with dynamic key expansion is carried out by the
vigenereDecryptDynamic function. It decrypts the ciphertext after generating a dynamic
key using the generateDynamicKey function with the ciphertext and keyword as inputs.
-The function GenerateDynamicKey creates a key with dynamic key expansion. The original
keyword is repeated until the text is the desired length, at which point the key is truncated
to fit the text.
-primary purpose: The primary function reads text from a file in plaintext, encrypts it using
Vigenere, writes the encrypted text to a file, retrieves the encrypted text from the file,
decrypts it using Vigenere, and writes the decoded content to a different file.
}
5. Your Design Constraints
5.1 Key Length
The suggested algorithm's security depends on choosing a sufficiently long, random term.
In order to increase the encryption strength, users are advised to select a strong keyword.
6. References
D. Singh, "Cryptography and Network Security," Tata McGraw-Hill Education, 2011.