Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satcom_cryptography
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KARABOGHOSSIAN Viken
satcom_cryptography
Commits
fe96075d
Commit
fe96075d
authored
Aug 27, 2023
by
Viken
Browse files
Options
Downloads
Patches
Plain Diff
Update
parent
d641365a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
automated_plots.py
+0
-119
0 additions, 119 deletions
automated_plots.py
interactive_plots.py
+0
-218
0 additions, 218 deletions
interactive_plots.py
with
0 additions
and
337 deletions
automated_plots.py
deleted
100644 → 0
+
0
−
119
View file @
d641365a
##################################################################################
################################# User Interface #################################
##################################################################################
from
rich.console
import
Console
from
rich.markdown
import
Markdown
from
rich.prompt
import
Prompt
console
=
Console
()
with
open
(
"
instruction.md
"
)
as
readme
:
markdown
=
Markdown
(
readme
.
read
())
console
.
print
(
markdown
)
start
=
Prompt
.
ask
(
"
:alarm_clock: Do you want to start?
"
,
choices
=
[
"
y
"
,
"
n
"
],
default
=
"
n
"
)
if
start
==
'
n
'
:
exit
(
1
)
mode
=
Prompt
.
ask
(
"
Which type of cipher do you want to plot ?
"
,
choices
=
[
"
block
"
,
"
stream
"
])
##################################################################################
##################################################################################
##################################################################################
############################## PLOTTING THE METRICS ##############################
##################################################################################
import
datetime
import
matplotlib.pyplot
as
plt
from
matplotlib
import
rc
import
csv
filepath
=
f
"
./csv_file/metrics_
{
mode
}
.csv
"
with
open
(
filepath
,
newline
=
''
)
as
csvfile
:
filereader
=
csv
.
reader
(
csvfile
,
delimiter
=
'
,
'
)
filedict
=
{}
filearray
=
[]
for
row
in
filereader
:
filedict
[
row
[
0
]
+
row
[
1
]
+
"
/
"
+
row
[
2
]
+
"
-
"
+
row
[
3
].
replace
(
"
"
,
""
)]
=
row
filearray
.
append
(
row
)
print
(
filearray
[
0
])
metrics_choices
=
[
'
encrypted_file_size
'
,
'
execution_time
'
,
'
implementation_size
'
,
'
memory_usage
'
,
'
ram_consumption
'
,
'
throughput
'
]
operation_choices
=
[
'
Decryption
'
,
'
Encryption
'
]
algo_choices
=
[
value
[
0
]
+
'
-
'
+
value
[
1
]
+
'
-
'
+
value
[
2
]
for
value
in
filearray
[
1
::
3
]]
# Plot for each metric
for
metric
in
metrics_choices
:
i
=
filearray
[
0
].
index
(
metric
)
final_bars
=
[]
# Get data for each operation
for
operation
in
operation_choices
:
operation_bars
=
[]
for
algorithm
in
algo_choices
:
# inside the filearray data
for
array
in
filearray
:
name
,
keysize
,
blocklen
=
algorithm
.
split
(
'
-
'
)
if
(
name
in
array
)
and
(
keysize
in
array
)
and
(
blocklen
in
array
)
and
(
operation
in
array
):
operation_bars
.
append
(
float
(
array
[
i
]))
break
final_bars
.
append
(
operation_bars
)
names
=
algo_choices
r
=
[]
for
i
in
range
(
len
(
names
)):
r
.
append
(
i
)
colors
=
[
'
black
'
,
'
red
'
,
'
green
'
,
'
blue
'
,
'
cyan
'
]
plt
.
barh
(
names
,
final_bars
[
0
],
color
=
'
blue
'
,
edgecolor
=
"
white
"
,
label
=
operation_choices
[
0
])
for
i
in
range
(
1
,
len
(
final_bars
)):
plt
.
barh
(
names
,
final_bars
[
i
],
left
=
final_bars
[
i
-
1
],
color
=
'
red
'
,
edgecolor
=
"
white
"
,
label
=
operation_choices
[
i
])
plt
.
legend
()
rc
(
'
font
'
,
weight
=
'
bold
'
)
plt
.
yticks
(
r
,
names
,
fontweight
=
'
bold
'
)
plt
.
ylabel
(
"
Algorithm name (key/block or nonce)
"
)
plt
.
title
(
metric
)
# Show graphic
plt
.
show
()
# Automatic saving
if
Prompt
.
ask
(
"
Do you want to save the plot ?
"
,
choices
=
[
'
y
'
,
'
n
'
],
default
=
'
n
'
):
plt
.
barh
(
names
,
final_bars
[
0
],
color
=
'
blue
'
,
edgecolor
=
"
white
"
,
label
=
operation_choices
[
0
])
for
i
in
range
(
1
,
len
(
final_bars
)):
plt
.
barh
(
names
,
final_bars
[
i
],
left
=
final_bars
[
i
-
1
],
color
=
'
red
'
,
edgecolor
=
"
white
"
,
label
=
operation_choices
[
i
])
plt
.
legend
()
rc
(
'
font
'
,
weight
=
'
bold
'
)
plt
.
yticks
(
r
,
names
,
fontweight
=
'
bold
'
)
plt
.
ylabel
(
"
Algorithm name (key/block or nonce)
"
)
plt
.
title
(
metric
)
date
=
datetime
.
datetime
.
now
()
plt
.
savefig
(
'
plots/
'
+
metric
+
'
-
'
+
str
(
date
.
year
)
+
str
(
date
.
month
)
+
str
(
date
.
day
)
+
'
-
'
+
str
(
date
.
hour
)
+
str
(
date
.
minute
)
+
'
.png
'
)
# Clear after saving
plt
.
clf
()
plt
.
cla
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
interactive_plots.py
deleted
100644 → 0
+
0
−
218
View file @
d641365a
# libraries
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
matplotlib
import
rc
import
pandas
as
pd
from
rich.prompt
import
Prompt
from
rich.emoji
import
Emoji
# y-axis in bold
rc
(
'
font
'
,
weight
=
'
bold
'
)
##################################################################################
################################# User Interface #################################
##################################################################################
from
rich.console
import
Console
from
rich.markdown
import
Markdown
console
=
Console
()
with
open
(
"
instructions.md
"
)
as
readme
:
markdown
=
Markdown
(
readme
.
read
())
console
.
print
(
markdown
)
start
=
Prompt
.
ask
(
"
:alarm_clock: Do you want to start?
"
,
choices
=
[
"
y
"
,
"
n
"
],
default
=
"
n
"
)
if
start
==
'
n
'
:
exit
(
1
)
mode
=
Prompt
.
ask
(
"
Which type of cipher do you want to analze ?
"
,
choices
=
[
"
block
"
,
"
stream
"
])
##################################################################################
##################################################################################
##################################################################################
################################### CSV reader ###################################
##################################################################################
import
csv
filepath
=
f
"
metrics_
{
mode
}
.csv
"
with
open
(
filepath
,
newline
=
''
)
as
csvfile
:
filereader
=
csv
.
reader
(
csvfile
,
delimiter
=
'
,
'
)
filedict
=
{}
filearray
=
[]
for
row
in
filereader
:
filedict
[
row
[
0
]
+
row
[
1
]
+
"
/
"
+
row
[
2
]
+
"
-
"
+
row
[
3
].
replace
(
"
"
,
""
)]
=
row
filearray
.
append
(
row
)
print
(
filearray
[
0
])
##################################################################################
##################################################################################
##################################################################################
################################### Prepare UI ###################################
##################################################################################
## Algorithms : preparation, prompt and selection
#################################################
algorithms
=
[]
for
array
in
filearray
:
algorithms
.
append
(
array
[
0
]
+
'
-
'
+
array
[
1
]
+
'
-
'
+
array
[
2
])
algorithms
.
remove
(
algorithms
[
0
])
algorithms
=
[
*
set
(
algorithms
)]
algorithms
.
sort
()
algorithms
.
append
(
"
STOP
"
)
algorithms
.
append
(
"
ALL
"
)
print
(
algorithms
)
condition
=
True
algo_choices
=
[]
while
condition
:
choice
=
Prompt
.
ask
(
"
:rocket: Which algorithm would you like to plot? (one at a time)
"
,
choices
=
algorithms
,
default
=
algorithms
[
-
1
])
if
"
STOP
"
in
choice
:
condition
=
False
elif
"
ALL
"
in
choice
:
condition
=
False
algo_choices
=
algorithms
[:
-
2
]
else
:
algo_choices
.
append
(
choice
)
print
(
f
"
Selected algorithms =
{
algo_choices
}
"
)
## Operations : preparation, prompt and selection
#################################################
operations
=
[]
for
array
in
filearray
:
operations
.
append
(
array
[
3
].
replace
(
"
"
,
""
))
operations
.
remove
(
operations
[
0
])
operations
=
[
*
set
(
operations
)]
operations
.
remove
(
"
Encryption+Decryption
"
)
operations
.
sort
()
operations
.
append
(
"
STOP
"
)
operations
.
append
(
"
ALL
"
)
print
(
operations
)
condition
=
True
operation_choices
=
[]
while
condition
:
choice
=
Prompt
.
ask
(
"
:rocket: Which operation would you like to visualize? (one at a time)
"
,
choices
=
operations
,
default
=
operations
[
-
1
])
if
"
STOP
"
in
choice
:
condition
=
False
elif
"
ALL
"
in
choice
:
condition
=
False
operation_choices
=
operations
[:
-
2
]
else
:
operation_choices
.
append
(
choice
)
print
(
f
"
Selected operations =
{
operation_choices
}
"
)
## Metrics : preparation, prompt and selection
##############################################
metrics
=
[]
metrics
=
filearray
[
0
][
5
:]
metrics
.
sort
()
metrics
.
append
(
"
STOP
"
)
metrics
.
append
(
"
ALL
"
)
print
(
metrics
)
condition
=
True
metrics_choices
=
[]
while
condition
:
choice
=
Prompt
.
ask
(
"
:rocket: Which metric would you like to study? (one at a time)
"
,
choices
=
metrics
,
default
=
metrics
[
-
1
])
if
"
STOP
"
in
choice
:
condition
=
False
elif
"
ALL
"
in
choice
:
condition
=
False
metrics_choices
=
metrics
[:
-
2
]
else
:
metrics_choices
.
append
(
choice
)
print
(
f
"
Selected metrics =
{
metrics_choices
}
"
)
##################################################################################
##################################################################################
# Plot for each metric
for
metric
in
metrics_choices
:
i
=
filearray
[
0
].
index
(
metric
)
print
(
i
)
final_bars
=
[]
# Get data for each operation
for
operation
in
operation_choices
:
operation_bars
=
[]
for
algorithm
in
algo_choices
:
# inside the filearray data
for
array
in
filearray
:
name
,
keysize
,
blocklen
=
algorithm
.
split
(
'
-
'
)
if
(
name
in
array
)
and
(
keysize
in
array
)
and
(
blocklen
in
array
)
and
(
operation
in
array
):
operation_bars
.
append
(
float
(
array
[
i
]))
break
final_bars
.
append
(
operation_bars
)
print
(
final_bars
)
####### TOUT FONCTIONNE JUSQUE LÀ
####### LE PLOT NE FONCTIONNE PAS
names
=
algo_choices
r
=
[]
for
i
in
range
(
len
(
names
)):
r
.
append
(
i
)
print
(
r
)
#colors=['b', 'c', 'g', 'k', 'm', 'r','y']
colors
=
[
'
black
'
,
'
red
'
,
'
green
'
,
'
blue
'
,
'
cyan
'
]
plt
.
barh
(
names
,
final_bars
[
0
],
color
=
'
blue
'
,
edgecolor
=
"
white
"
,
label
=
operation_choices
[
0
])
#plt.barh(names, final_bars[1],color='red',edgecolor="white")
for
i
in
range
(
1
,
len
(
final_bars
)):
plt
.
barh
(
names
,
final_bars
[
i
],
left
=
final_bars
[
i
-
1
],
color
=
'
red
'
,
edgecolor
=
"
white
"
,
label
=
operation_choices
[
i
])
plt
.
legend
()
# Custom X axis
plt
.
yticks
(
r
,
names
,
fontweight
=
'
bold
'
)
plt
.
ylabel
(
"
Algorithm name
"
)
plt
.
title
(
metric
)
# Show graphic
plt
.
show
()
############
###########
# values = np.array(final_bars)
# fig, ax = plt.subplots()
# # Stacked bar chart with loop
# for i in range(values.shape[0]):
# ax.barh(names, values[i], left = np.sum(values[:i], axis = 0))
#plt.show()
# encryptionBarsRAM = [1276.27,1239.7,1240.0]
# decryptionBarsRAM = [1244.2,1240.0,1240.0]
# # Heights of bars1 + bars2
# bars = np.add(encryptionBarsRAM, decryptionBarsRAM).tolist()
# # The position of the bars on the x-axis
# r = [0,1,2]
# # Names of group and bar width
# names = ['AES16/16','AES24/16','AES32/16']
# barWidth = 0.5
# # Create brown bars
# plt.barh(names, encryptionBarsRAM, color='#7f6d5f', edgecolor='white')#, width=barWidth)
# # Create green bars (middle), on top of the first ones
# plt.barh(names, decryptionBarsRAM, left=encryptionBarsRAM, color='#557f2d', edgecolor='white')#, width=barWidth)
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