FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaDataStructures/ECC/Decoder.java at master · tjock/JavaDataStructures · GitHub
tjock
/
JavaDataStructures
Public
forked from
benaich/JavaDataStructures
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaDataStructures
/
ECC
/
Decoder.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (47 loc) · 1.71 KB
Breadcrumbs
JavaDataStructures
/
ECC
/
Decoder.java
Copy path
File metadata and controls
54 lines (47 loc) · 1.71 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package
ECC
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
List
;
public
class
Decoder
{
public
static
int
PAD
=
5
;
private
HashMap
<
Point
,
Integer
>
pointTable
;
public
Decoder
(
HashMap
<
Point
,
Integer
>
pointTable
) {
this
.
pointTable
=
pointTable
;
}
public
String
decode
(
Matrix
A
) {
List
<
String
>
subKeys
=
Helpers
.
getSubKeys
();
for
(
String
subKey
:
subKeys
) {
String
[]
array
=
subKey
.
split
(
"
\\
/"
);
String
transformation
=
array
[
0
];
int
op
=
Integer
.
parseInt
(
array
[
1
]);
int
a
=
Integer
.
parseInt
(
array
[
2
]);
int
b
=
Integer
.
parseInt
(
array
[
3
]);
int
c
=
Integer
.
parseInt
(
array
[
4
]);
int
d
=
Integer
.
parseInt
(
array
[
5
]);
if
(
transformation
.
equals
(
"R"
)) {
A
.
reverseRowTrasformation
(
a
,
c
,
d
,
op
);
A
.
reverseRowTrasformation
(
b
,
c
,
d
,
op
);
}
else
{
A
.
reverseColumnTrasformation
(
a
,
c
,
d
,
op
);
A
.
reverseColumnTrasformation
(
b
,
c
,
d
,
op
);
}
System
.
out
.
println
(
"sub-key : "
+
subKey
);
System
.
out
.
println
(
A
);
}
return
getPlainText
(
A
);
}
private
String
getPlainText
(
Matrix
A
) {
String
plaintText
=
""
;
System
.
out
.
println
(
"4) Convert the matrix M to a list of points"
);
A
.
toPoints
().
stream
().
forEach
(
System
.
out
::
print
);
System
.
out
.
println
(
""
);
for
(
Point
p
:
A
.
toPoints
()) {
if
(
pointTable
.
get
(
p
) !=
null
) {
int
asciCode
=
pointTable
.
get
(
p
);
plaintText
+=
Character
.
toString
((
char
)
asciCode
);
}
else
{
plaintText
+=
"$"
;
}
}
return
plaintText
;
}
}
Back
|
FazBrowse Home
|
New Git URL