Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
play-unfair
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
Harbor Registry
Model registry
Operate
Environments
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
Marcela Ribeiro de Oliveira
play-unfair
Commits
e80f2733
Commit
e80f2733
authored
7 years ago
by
Marcela Ribeiro de Oliveira
Browse files
Options
Downloads
Patches
Plain Diff
programa para criar o texto cifrado
parent
ed646bef
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
Makefile
+11
-6
11 additions, 6 deletions
Makefile
cypher.cpp
+51
-0
51 additions, 0 deletions
cypher.cpp
key.txt
+1
-0
1 addition, 0 deletions
key.txt
playfair.cpp
+2
-2
2 additions, 2 deletions
playfair.cpp
with
66 additions
and
8 deletions
.gitignore
+
1
−
0
View file @
e80f2733
...
...
@@ -3,3 +3,4 @@
*.swo
playunfair
*.out
cypher
This diff is collapsed.
Click to expand it.
Makefile
+
11
−
6
View file @
e80f2733
...
...
@@ -5,18 +5,23 @@ INCL = -I ./include
DEPS
=
include/
*
OBJ
=
playfair.o
playunfair.o
OBJ
=
playfair.o
EXEC
=
playunfair
EXEC
=
playunfair
cypher
$(EXEC)
:
$(OBJ)
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
all
:
$(EXEC)
playunfair
:
$(OBJ)
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
$@
.o
cypher
:
$(OBJ)
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
$@
.o
%.o
:
%.cpp $(DEPS)
$(
CC
)
$(
CFLAGS
)
-c
-o
$@
$<
$(
INCL
)
all
:
$(EXEC)
clean
:
rm
-f
$(
OBJ
)
playunfair
rm
-f
$(
OBJ
)
$(
EXEC
)
This diff is collapsed.
Click to expand it.
cypher.cpp
0 → 100644
+
51
−
0
View file @
e80f2733
#include
"include/playunfair.h"
#include
<fstream>
int
main
(
int
argc
,
char
*
argv
[]){
if
(
argc
!=
3
){
std
::
cout
<<
"Uso: ./playunfair <file-in> <key>"
<<
std
::
endl
;
return
0
;
}
std
::
fstream
input
,
keyF
;
char
*
inputName
,
*
keyName
;
std
::
string
aux
=
""
,
key
,
crip
;
std
::
ostringstream
text
,
keys
;
inputName
=
argv
[
1
];
keyName
=
argv
[
2
];
input
.
open
(
inputName
,
std
::
ifstream
::
in
);
if
(
!
input
.
good
()){
std
::
cout
<<
"Nao foi possivel abrir o arquivo de entrada"
<<
std
::
endl
;
return
0
;
}
while
(
std
::
getline
(
input
,
aux
))
text
<<
aux
;
//TODO: tirar caracteres especiais
crip
=
text
.
str
();
parser
(
crip
);
//std::cout << crip << std::endl;
keyF
.
open
(
keyName
,
std
::
ifstream
::
in
);
if
(
!
keyF
.
good
()){
std
::
cout
<<
"Nao foi possivel abrir o dicionario"
<<
std
::
endl
;
return
0
;
}
//TODO: if filter returns accepted print key and text in file
std
::
getline
(
keyF
,
aux
);
keys
<<
aux
;
key
=
keys
.
str
();
crip
=
playfair
(
crip
,
key
,
CRYPT
);
std
::
cout
<<
crip
<<
std
::
endl
;
return
0
;
}
void
parser
(
std
::
string
&
text
){
text
.
erase
(
std
::
remove
(
text
.
begin
(),
text
.
end
(),
' '
),
text
.
end
());
std
::
transform
(
text
.
begin
(),
text
.
end
(),
text
.
begin
(),
::
tolower
);
}
This diff is collapsed.
Click to expand it.
key.txt
0 → 100644
+
1
−
0
View file @
e80f2733
cachorro
This diff is collapsed.
Click to expand it.
playfair.cpp
+
2
−
2
View file @
e80f2733
...
...
@@ -32,12 +32,12 @@ std::string playfair(std::string text, const std::string key, int crypt){
crypt
=
crypt
+
5
;
//Avoid operator % on negative numbers
std
::
ostringstream
ret
;
std
::
vector
<
char
>
mKey
(
createKM
(
key
));
for
(
int
i
=
0
;
i
<
5
;
++
i
){
/*
for (int i=0; i<5; ++i){
for (int j=0; j<5; ++j){
std::cout << mKey[i*5 + j] << ' ';
}
std::cout << std::endl;
}
}
*/
unsigned
int
indexT
=
0
;
while
(
indexT
<
text
.
size
()
){
...
...
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