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
9dd164cc
Commit
9dd164cc
authored
6 years ago
by
Marcela Ribeiro de Oliveira
Browse files
Options
Downloads
Patches
Plain Diff
primeiros dois filtros
parent
b69ddd32
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Makefile
+5
-5
5 additions, 5 deletions
Makefile
cypher.cpp
+0
-1
0 additions, 1 deletion
cypher.cpp
include/playunfair.h
+1
-1
1 addition, 1 deletion
include/playunfair.h
key.txt
+1
-1
1 addition, 1 deletion
key.txt
playunfair.cpp
+37
-12
37 additions, 12 deletions
playunfair.cpp
with
44 additions
and
20 deletions
Makefile
+
5
−
5
View file @
9dd164cc
...
...
@@ -11,17 +11,17 @@ EXEC = playunfair cypher
all
:
$(EXEC)
playunfair
:
$(OBJ)
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
$@
.o
playunfair
:
$(OBJ)
playunfair.o
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
cypher
:
$(OBJ)
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
$@
.o
cypher
:
$(OBJ)
cypher.o
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
%.o
:
%.cpp $(DEPS)
$(
CC
)
$(
CFLAGS
)
-c
-o
$@
$<
$(
INCL
)
clean
:
rm
-f
$(
OBJ
)
$(
EXEC
)
rm
-f
*
.o
$(
OBJ
)
$(
EXEC
)
This diff is collapsed.
Click to expand it.
cypher.cpp
+
0
−
1
View file @
9dd164cc
...
...
@@ -24,7 +24,6 @@ int main(int argc, char *argv[]){
while
(
std
::
getline
(
input
,
aux
))
text
<<
aux
;
//TODO: tirar caracteres especiais
crip
=
text
.
str
();
parser
(
crip
);
//std::cout << crip << std::endl;
...
...
This diff is collapsed.
Click to expand it.
include/playunfair.h
+
1
−
1
View file @
9dd164cc
...
...
@@ -2,5 +2,5 @@
#define ACCEPTED 1
#define REJECTED 0
int
filter
(
std
::
string
text
,
const
std
::
string
key
);
int
filter
(
std
::
string
text
);
void
parser
(
std
::
string
&
text
);
This diff is collapsed.
Click to expand it.
key.txt
+
1
−
1
View file @
9dd164cc
ca
chorro
ca
sa
This diff is collapsed.
Click to expand it.
playunfair.cpp
+
37
−
12
View file @
9dd164cc
...
...
@@ -9,7 +9,7 @@ int main(int argc, char *argv[]){
}
std
::
fstream
input
,
output
,
dict
;
char
*
inputName
,
*
outputName
,
*
dictName
;
std
::
string
aux
=
""
,
key
,
crip
;
//a key vai vir do dicionario futuramente
std
::
string
aux
=
""
,
key
,
crip
;
std
::
ostringstream
text
,
keys
;
inputName
=
argv
[
1
];
...
...
@@ -25,11 +25,8 @@ int main(int argc, char *argv[]){
while
(
std
::
getline
(
input
,
aux
))
text
<<
aux
;
//TODO: tirar caracteres especiais
std
::
cout
<<
text
.
str
()[
2
]
<<
std
::
endl
;
crip
=
text
.
str
();
parser
(
crip
);
//std::cout << crip << std::endl;
dict
.
open
(
dictName
,
std
::
ifstream
::
in
);
if
(
!
dict
.
good
()){
...
...
@@ -37,20 +34,19 @@ int main(int argc, char *argv[]){
return
0
;
}
//TODO: if filter returns accepted print key and text in file
while
(
std
::
getline
(
dict
,
aux
)){
keys
<<
aux
;
key
=
keys
.
str
();
crip
=
playfair
(
crip
,
key
,
DECRYPT
);
std
::
cout
<<
crip
<<
std
::
endl
;
std
::
cout
<<
key
<<
std
::
endl
;
if
(
filter
(
crip
)
==
ACCEPTED
){
std
::
cout
<<
crip
<<
std
::
endl
;
std
::
cout
<<
key
<<
std
::
endl
;
}
keys
.
str
(
""
);
keys
.
clear
();
filter
(
crip
,
key
);
//chamar filtro para cada key
}
//crip = playfair(crip, key, DECRYPT);
//std::cout << crip << std::endl;
std
::
cout
<<
crip
<<
std
::
endl
;
return
0
;
}
...
...
@@ -59,7 +55,7 @@ void parser(std::string &text){
std
::
transform
(
text
.
begin
(),
text
.
end
(),
text
.
begin
(),
::
tolower
);
}
int
filter
(
std
::
string
text
,
const
std
::
string
key
){
int
filter
(
std
::
string
text
){
//TODO: if ( 4 primeiras letras sem vogal ||
// 3 char -('o') iguais seguidos ||
// 5 consoantes ||
...
...
@@ -69,6 +65,35 @@ int filter(std::string text, const std::string key){
//
// )
// { elimina texto: muda pra proxima chave}
int
i
,
j
,
rej
=
REJECTED
;
for
(
int
i
=
0
;
i
<
4
;
++
i
){
if
(
text
[
i
]
==
'a'
||
text
[
i
]
==
'e'
||
text
[
i
]
==
'i'
||
text
[
i
]
==
'o'
||
text
[
i
]
==
'u'
){
rej
=
ACCEPTED
;
break
;
}
}
for
(
i
=
0
;
i
<
text
.
size
()
-
3
;
++
i
){
char
l
=
text
[
i
];
int
lim
=
3
,
cont
=
0
;
if
(
l
==
'o'
)
continue
;
for
(
j
=
i
+
1
;
j
<
i
+
lim
;
++
j
){
if
(
text
[
j
]
==
'x'
){
++
lim
;
continue
;
}
else
if
(
text
[
j
]
==
l
){
++
cont
;
continue
;
}
if
(
text
[
j
]
!=
l
){
break
;
}
}
if
(
cont
==
2
)
{
rej
=
REJECTED
;
break
;
}
}
return
ACCEPTED
;
return
rej
;
}
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