Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Criptografia T2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mgh16
Criptografia T2
Commits
e3b33140
Commit
e3b33140
authored
2 years ago
by
mgh16
Browse files
Options
Downloads
Patches
Plain Diff
teje pronto
parent
a5d492b1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cifra_railOnSteroids.c
+0
-4
0 additions, 4 deletions
cifra_railOnSteroids.c
decifra_railOnSteroids.c
+2
-8
2 additions, 8 deletions
decifra_railOnSteroids.c
with
2 additions
and
12 deletions
cifra_railOnSteroids.c
+
0
−
4
View file @
e3b33140
...
...
@@ -47,11 +47,9 @@ int main(){
for
(
int
itr
=
0
;
itr
<
num_chaves
;
itr
++
){
printf
(
"itr %d de %d
\n
"
,
itr
,
num_chaves
);
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
;
printf
(
"completando %d caracteres, texto tinha %d
\n
"
,
caracteres_p_completar
,
tamanho_texto
);
...
...
@@ -66,14 +64,12 @@ int main(){
int
caracteresporlinha
=
(
tamanho_texto
+
mod_text_pela_chave
)
/
chaves_parciais
[
itr
];
printf
(
"caracteres por linha = %d
\n
"
,
caracteresporlinha
);
char
matrizTransposicao
[
10
][
caracteresporlinha
];
int
caracter
=
0
;
for
(
int
j
=
0
;
j
<
caracteresporlinha
;
j
++
){
for
(
int
i
=
0
;
i
<
chaves_parciais
[
itr
];
i
++
){
printf
(
"linha %d coluna %d caracter %c
\n
"
,
i
,
j
,
texto_cifrado
[
caracter
]);
matrizTransposicao
[
i
][
j
]
=
texto_cifrado
[
caracter
];
caracter
++
;
}
...
...
This diff is collapsed.
Click to expand it.
decifra_railOnSteroids.c
+
2
−
8
View file @
e3b33140
...
...
@@ -11,9 +11,9 @@ int main(){
char
texto_cifrado
[
TAM_MAX_TEXTO
]
;
long
int
chave
;
puts
(
"digite o texto a ser cifrado"
);
puts
(
"digite o texto a ser
de
cifrado"
);
fgets
(
texto_claro
,
sizeof
texto_claro
,
stdin
);
puts
(
"digite a chave
(inteiros) para cifrar o texto
"
);
puts
(
"digite a chave"
);
scanf
(
"%ld"
,
&
chave
);
...
...
@@ -51,7 +51,6 @@ int main(){
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
;
printf
(
"completando %d caracteres, texto tinha %d
\n
"
,
caracteres_p_completar
,
tamanho_texto
);
for
(
int
i
=
0
;
i
<
caracteres_p_completar
;
i
++
){
texto_cifrado
[
tamanho_texto
+
i
]
=
'='
;
...
...
@@ -59,18 +58,14 @@ int main(){
tamanho_texto
+=
caracteres_p_completar
;
printf
(
"itr %d de %d
\n
"
,
itr
,
num_chaves
);
if
(
mod_text_pela_chave
!=
0
)
puts
(
"algo errado deu pq mod deu dif de 0"
);
int
caracteresporlinha
=
(
tamanho_texto
)
/
chaves_parciais
[
itr
];
printf
(
"caracteres por linha = %d
\n
"
,
caracteresporlinha
);
char
matrizTransposicao
[
10
][
caracteresporlinha
];
int
caracter
=
0
;
for
(
int
i
=
0
;
i
<
chaves_parciais
[
itr
];
i
++
){
for
(
int
j
=
0
;
j
<
caracteresporlinha
;
j
++
){
printf
(
"linha %d coluna %d caracter %c
\n
"
,
i
,
j
,
texto_cifrado
[
caracter
]);
matrizTransposicao
[
i
][
j
]
=
texto_cifrado
[
caracter
];
caracter
++
;
}
...
...
@@ -88,7 +83,6 @@ int main(){
}
while
(
texto_cifrado
[
tamanho_texto
-
1
]
==
'='
){
puts
(
"removendo um ="
);
tamanho_texto
--
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment