Skip to content
Snippets Groups Projects
Commit 745924b7 authored by mgh16's avatar mgh16
Browse files

fixed 0 key

parent e3b33140
Branches main
No related tags found
No related merge requests found
...@@ -47,6 +47,7 @@ int main(){ ...@@ -47,6 +47,7 @@ int main(){
for(int itr = 0; itr < num_chaves; itr++){ for(int itr = 0; itr < num_chaves; itr++){
if(chaves_parciais[itr] != 0){
int mod_text_pela_chave = (tamanho_texto) % chaves_parciais[itr]; int mod_text_pela_chave = (tamanho_texto) % chaves_parciais[itr];
int caracteres_p_completar =(mod_text_pela_chave > 0) ? chaves_parciais[itr]-mod_text_pela_chave : 0; int caracteres_p_completar =(mod_text_pela_chave > 0) ? chaves_parciais[itr]-mod_text_pela_chave : 0;
...@@ -79,12 +80,12 @@ int main(){ ...@@ -79,12 +80,12 @@ int main(){
for(int i=0; i < chaves_parciais[itr]; i++){ for(int i=0; i < chaves_parciais[itr]; i++){
for(int j=0; j<caracteresporlinha; j++){ for(int j=0; j<caracteresporlinha; j++){
if(caracter < tamanho_texto){ if(caracter < tamanho_texto){
printf("%c\n", matrizTransposicao[i][j]);
texto_cifrado[caracter] = matrizTransposicao[i][j]; texto_cifrado[caracter] = matrizTransposicao[i][j];
} }
caracter++; caracter++;
} }
} }
}
} }
......
...@@ -47,7 +47,7 @@ int main(){ ...@@ -47,7 +47,7 @@ int main(){
for(int itr = 0; itr < num_chaves; itr++){ for(int itr = 0; itr < num_chaves; itr++){
if(chaves_parciais[itr] != 0){
int mod_text_pela_chave = (tamanho_texto) % chaves_parciais[itr]; int mod_text_pela_chave = (tamanho_texto) % chaves_parciais[itr];
int caracteres_p_completar =(mod_text_pela_chave > 0) ? chaves_parciais[itr]-mod_text_pela_chave : 0; int caracteres_p_completar =(mod_text_pela_chave > 0) ? chaves_parciais[itr]-mod_text_pela_chave : 0;
...@@ -75,7 +75,6 @@ int main(){ ...@@ -75,7 +75,6 @@ int main(){
for(int j=0; j<caracteresporlinha; j++){ for(int j=0; j<caracteresporlinha; j++){
for(int i=0; i < chaves_parciais[itr]; i++){ for(int i=0; i < chaves_parciais[itr]; i++){
if(caracter < tamanho_texto){ if(caracter < tamanho_texto){
printf("%c\n", matrizTransposicao[i][j]);
texto_cifrado[caracter] = matrizTransposicao[i][j]; texto_cifrado[caracter] = matrizTransposicao[i][j];
} }
caracter++; caracter++;
...@@ -86,7 +85,7 @@ int main(){ ...@@ -86,7 +85,7 @@ int main(){
tamanho_texto--; tamanho_texto--;
} }
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment