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
b72ebb50
Commit
b72ebb50
authored
7 years ago
by
Marcela Ribeiro de Oliveira
Browse files
Options
Downloads
Patches
Plain Diff
implementado filtro 2 e corrigindo filtro 2 e 3
parent
740ca981
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/playunfair.h
+2
-1
2 additions, 1 deletion
include/playunfair.h
key.txt
+1
-1
1 addition, 1 deletion
key.txt
playunfair.cpp
+40
-8
40 additions, 8 deletions
playunfair.cpp
with
43 additions
and
10 deletions
include/playunfair.h
+
2
−
1
View file @
b72ebb50
...
...
@@ -8,3 +8,4 @@ void parser(std::string &text);
int
filter1
(
std
::
string
text
);
int
filter2
(
std
::
string
text
);
int
filter3
(
std
::
string
text
);
int
filter4
(
std
::
string
text
);
This diff is collapsed.
Click to expand it.
key.txt
+
1
−
1
View file @
b72ebb50
cas
a
cas
This diff is collapsed.
Click to expand it.
playunfair.cpp
+
40
−
8
View file @
b72ebb50
...
...
@@ -26,6 +26,7 @@ int main(int argc, char *argv[]){
crip
=
text
.
str
();
parser
(
crip
);
std
::
cout
<<
crip
<<
std
::
endl
;
dict
.
open
(
dictName
,
std
::
ifstream
::
in
);
if
(
!
dict
.
good
()){
...
...
@@ -36,9 +37,9 @@ int main(int argc, char *argv[]){
while
(
std
::
getline
(
dict
,
aux
)){
keys
<<
aux
;
key
=
keys
.
str
();
crip
=
playfair
(
crip
,
key
,
DECRYPT
);
if
(
filter
(
c
rip
)
==
ACCEPTED
){
std
::
cout
<<
key
<<
": "
<<
c
rip
<<
std
::
endl
;
std
::
string
cypher
=
playfair
(
crip
,
key
,
DECRYPT
);
if
(
filter
(
c
ypher
)
==
ACCEPTED
){
std
::
cout
<<
key
<<
": "
<<
c
ypher
<<
std
::
endl
;
}
keys
.
str
(
""
);
keys
.
clear
();
...
...
@@ -63,7 +64,14 @@ int filter(std::string text){
//
// )
// { elimina texto: muda pra proxima chave}
return
(
filter1
(
text
)
&&
filter2
(
text
)
&&
filter3
(
text
));
if
(
filter1
(
text
)
==
REJECTED
)
return
REJECTED
;
else
if
(
filter2
(
text
)
==
REJECTED
)
return
REJECTED
;
else
if
(
filter3
(
text
)
==
REJECTED
)
return
REJECTED
;
else
return
filter4
(
text
);
}
int
isVowel
(
char
c
){
...
...
@@ -75,8 +83,7 @@ int isVowel(char c){
int
filter1
(
std
::
string
text
){
int
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'
){
if
(
isVowel
(
text
[
i
])){
rej
=
ACCEPTED
;
break
;
}
...
...
@@ -90,7 +97,7 @@ int filter2(std::string text){
for
(
i
=
0
;
i
<
text
.
size
()
-
3
;
++
i
){
char
l
=
text
[
i
];
int
lim
=
3
,
cont
=
0
;
if
(
l
==
'o'
)
if
(
(
l
==
'o'
)
||
(
l
==
'e'
))
continue
;
for
(
j
=
i
+
1
;
j
<
i
+
lim
;
++
j
){
if
(
text
[
j
]
==
'x'
){
...
...
@@ -130,7 +137,32 @@ int filter3(std::string text){
break
;
}
}
if
(
cont
==
5
){
if
(
cont
==
4
){
rej
=
REJECTED
;
break
;
}
}
return
rej
;
}
int
filter4
(
std
::
string
text
){
size_t
i
,
j
;
int
rej
=
ACCEPTED
;
for
(
i
=
0
;
i
<
text
.
size
()
-
7
;
++
i
){
int
lim
=
7
,
cont
=
0
;
char
l
=
text
[
i
];
if
(
isVowel
(
l
))
++
cont
;
for
(
j
=
i
+
1
;
j
<
i
+
lim
;
++
j
){
if
(
text
[
j
]
==
'x'
){
++
lim
;
}
else
if
(
isVowel
(
text
[
j
])){
++
cont
;
}
else
if
(
!
isVowel
(
text
[
j
])){
break
;
}
}
if
(
cont
==
7
){
rej
=
REJECTED
;
break
;
}
...
...
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