Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Nascondi spazi bianchi
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Stili testo
Modifica aspetto
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
Untitled diff
Creato
10 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
16 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
93 linee
Copia tutti
14 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
92 linee
Copia tutti
#include <stdio.h>
#include <stdio.h>
#include <cs50.h>
#include <cs50.h>
#include <string.h>
#include <string.h>
#include <ctype.h>
#include <ctype.h>
#include <math.h>
#include <math.h>
void EncryptLower(int key, char i);
void EncryptLower(int key, char i);
void EncryptUpper(int key, char i);
void EncryptUpper(int key, char i);
int WhichArray(char* keyword, int CharNum);
int WhichArray(char* keyword, int CharNum);
int main(int argc, string argv[])
int main(int argc, string argv[])
{
{
if (argc != 2)
if (argc != 2)
{
{
printf("Please enter one key after ./vigenere\n.");
printf("Please enter one key after ./vigenere\n.");
return 1; // Make sure that 2 arguments are passed into the program else exit and return 1 as error message
return 1; // Make sure that 2 arguments are passed into the program else exit and return 1 as error message
}
}
Copia
Copiato
Copia
Copiato
char* keyword = argv[1]; // Assign the key into a variable
//
char* keyword = argv[1]; // Assign the key into a variable
//if (isalpha(keyword) != true) // Check that the key is all letters
//if (isalpha(keyword) != true) // Check that the key is all letters
//{
//{
// return 1; // Exit program
// return 1; // Exit program
//}
//}
Copia
Copiato
Copia
Copiato
char*
message = GetString(); // Store the message
string
message = GetString(); // Store the message
Copia
Copiato
Copia
Copiato
int z = strlen(message);
//
int z = strlen(message);
//
int shift[
z
];
int shift[
strlen(argv[1])
];
Copia
Copiato
Copia
Copiato
for(int a = 0, n = strlen(
keyword
); a < n; a++) //Go through the characters of the key and create an array of keys to use
for(int a = 0, n = strlen(
argv[1]
); a < n; a++) //Go through the characters of the key and create an array of keys to use
{
{
Copia
Copiato
Copia
Copiato
if(isupper(
keyword
[a]))
if(isupper(
argv[1]
[a]))
{
{
Copia
Copiato
Copia
Copiato
int
shift[
n
] =
keyword
[a] - 65; // populate the array with an index to encrypt with
shift[
a
] =
argv[1]
[a] - 65; // populate the array with an index to encrypt with
}
}
Copia
Copiato
Copia
Copiato
else if(islower(
argv[1]
[a]))
else if(islower(
keyword
[a]))
{
{
Copia
Copiato
Copia
Copiato
int
shift[
n
] =
keyword
[a] - 97; // populate the array with an index to encrypt with
shift[
a
] =
argv[1]
[a] - 97; // populate the array with an index to encrypt with
}
}
}
}
for(int i = 0, x = strlen(message); i < x; i++) // for first to last character
for(int i = 0, x = strlen(message); i < x; i++) // for first to last character
{
{
if(isalpha(message[i])) // Check if the value is a character
if(isalpha(message[i])) // Check if the value is a character
{
{
if(islower(message[i])) // check if the value is lowercase
if(islower(message[i])) // check if the value is lowercase
{
{
Copia
Copiato
Copia
Copiato
int key0 = shift [WhichArray(
keyword
, i)]; // which array will find which number of array to pull this should work.
int key0 = shift [WhichArray(
argv[1]
, i)]; // which array will find which number of array to pull this should work.
EncryptLower(key0, message[i]);
EncryptLower(key0, message[i]);
}
}
else if(isupper(message[i])) //check if the the value is uppercase
else if(isupper(message[i])) //check if the the value is uppercase
{
{
Copia
Copiato
Copia
Copiato
int key1 = shift [WhichArray(
keyword
, i)];
int key1 = shift [WhichArray(
argv[1]
, i)];
EncryptUpper(key1, message[i]);
EncryptUpper(key1, message[i]);
}
}
}
}
else
else
{
{
printf("%c", message[i]); // Not sure if this will work, print any charcter not encrypted eg. a number or brackets
printf("%c", message[i]); // Not sure if this will work, print any charcter not encrypted eg. a number or brackets
}
}
}
}
printf("\n");
printf("\n");
return 0;
return 0;
}
}
void EncryptLower(int key, char i) // Encrypt Lowercase letters
void EncryptLower(int key, char i) // Encrypt Lowercase letters
{
{
int cipher = ((i + key - 97) % 26) + 97; //encrypt the char
int cipher = ((i + key - 97) % 26) + 97; //encrypt the char
printf("%c", cipher); // print the encrypted char
printf("%c", cipher); // print the encrypted char
}
}
void EncryptUpper(int key, char i) // Encrypt the uppercase letters
void EncryptUpper(int key, char i) // Encrypt the uppercase letters
{
{
int cipher = ((i + key - 65) % 26) + 65; // encrypt the char
int cipher = ((i + key - 65) % 26) + 65; // encrypt the char
printf("%c", cipher); // print the encrypted char
printf("%c", cipher); // print the encrypted char
}
}
int WhichArray(char* keyword, int CharNum) // Find out which array to go into, CharNum is the character number in the string
int WhichArray(char* keyword, int CharNum) // Find out which array to go into, CharNum is the character number in the string
{
{
int x = CharNum % strlen(keyword);
int x = CharNum % strlen(keyword);
return x;
return x;
}
}
Diff salvati
Testo originale
Apri file
#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <math.h> void EncryptLower(int key, char i); void EncryptUpper(int key, char i); int WhichArray(char* keyword, int CharNum); int main(int argc, string argv[]) { if (argc != 2) { printf("Please enter one key after ./vigenere\n."); return 1; // Make sure that 2 arguments are passed into the program else exit and return 1 as error message } char* keyword = argv[1]; // Assign the key into a variable //if (isalpha(keyword) != true) // Check that the key is all letters //{ // return 1; // Exit program //} char* message = GetString(); // Store the message int z = strlen(message); //int shift[z]; for(int a = 0, n = strlen(keyword); a < n; a++) //Go through the characters of the key and create an array of keys to use { if(isupper(keyword[a])) { int shift[n] = keyword[a] - 65; // populate the array with an index to encrypt with } else if(islower(keyword[a])) { int shift[n] = keyword[a] - 97; // populate the array with an index to encrypt with } } for(int i = 0, x = strlen(message); i < x; i++) // for first to last character { if(isalpha(message[i])) // Check if the value is a character { if(islower(message[i])) // check if the value is lowercase { int key0 = shift [WhichArray(keyword, i)]; // which array will find which number of array to pull this should work. EncryptLower(key0, message[i]); } else if(isupper(message[i])) //check if the the value is uppercase { int key1 = shift [WhichArray(keyword, i)]; EncryptUpper(key1, message[i]); } } else { printf("%c", message[i]); // Not sure if this will work, print any charcter not encrypted eg. a number or brackets } } printf("\n"); return 0; } void EncryptLower(int key, char i) // Encrypt Lowercase letters { int cipher = ((i + key - 97) % 26) + 97; //encrypt the char printf("%c", cipher); // print the encrypted char } void EncryptUpper(int key, char i) // Encrypt the uppercase letters { int cipher = ((i + key - 65) % 26) + 65; // encrypt the char printf("%c", cipher); // print the encrypted char } int WhichArray(char* keyword, int CharNum) // Find out which array to go into, CharNum is the character number in the string { int x = CharNum % strlen(keyword); return x; }
Testo modificato
Apri file
#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <math.h> void EncryptLower(int key, char i); void EncryptUpper(int key, char i); int WhichArray(char* keyword, int CharNum); int main(int argc, string argv[]) { if (argc != 2) { printf("Please enter one key after ./vigenere\n."); return 1; // Make sure that 2 arguments are passed into the program else exit and return 1 as error message } //char* keyword = argv[1]; // Assign the key into a variable //if (isalpha(keyword) != true) // Check that the key is all letters //{ // return 1; // Exit program //} string message = GetString(); // Store the message //int z = strlen(message); int shift[strlen(argv[1])]; for(int a = 0, n = strlen(argv[1]); a < n; a++) //Go through the characters of the key and create an array of keys to use { if(isupper(argv[1][a])) { shift[a] = argv[1][a] - 65; // populate the array with an index to encrypt with } else if(islower(argv[1][a])) { shift[a] = argv[1][a] - 97; // populate the array with an index to encrypt with } } for(int i = 0, x = strlen(message); i < x; i++) // for first to last character { if(isalpha(message[i])) // Check if the value is a character { if(islower(message[i])) // check if the value is lowercase { int key0 = shift [WhichArray(argv[1], i)]; // which array will find which number of array to pull this should work. EncryptLower(key0, message[i]); } else if(isupper(message[i])) //check if the the value is uppercase { int key1 = shift [WhichArray(argv[1], i)]; EncryptUpper(key1, message[i]); } } else { printf("%c", message[i]); // Not sure if this will work, print any charcter not encrypted eg. a number or brackets } } printf("\n"); return 0; } void EncryptLower(int key, char i) // Encrypt Lowercase letters { int cipher = ((i + key - 97) % 26) + 97; //encrypt the char printf("%c", cipher); // print the encrypted char } void EncryptUpper(int key, char i) // Encrypt the uppercase letters { int cipher = ((i + key - 65) % 26) + 65; // encrypt the char printf("%c", cipher); // print the encrypted char } int WhichArray(char* keyword, int CharNum) // Find out which array to go into, CharNum is the character number in the string { int x = CharNum % strlen(keyword); return x; }
Trovare la differenza