refactor loose files
This commit is contained in:
172
notebooks/nkode_calculation.ipynb
Normal file
172
notebooks/nkode_calculation.ipynb
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# What does is take to compromise a users nKode in the worst case scenario?\n"
|
||||
],
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def compute_time_to_crack_hash(\n",
|
||||
" num_of_attributes: int,\n",
|
||||
" nkode_len,\n",
|
||||
" secs_per_hash: float = 0.5,\n",
|
||||
") -> list[float, float]:\n",
|
||||
" secs_to_days = 1/(60*60*24)\n",
|
||||
" secs_to_years = secs_to_days / 365\n",
|
||||
" total_secs_to_compute_half_of_hashes = num_of_attributes ** nkode_len * secs_per_hash * 0.5\n",
|
||||
" return [round(total_secs_to_compute_half_of_hashes * secs_to_days, 2), round(total_secs_to_compute_half_of_hashes * secs_to_years, 2)]\n"
|
||||
],
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-07-26T15:29:35.667921Z",
|
||||
"start_time": "2024-07-26T15:29:35.664278Z"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def matrix_to_md_table(col_names: list[str], mat: list[list[any]]) -> str:\n",
|
||||
" assert len(col_names) == len(mat[0])\n",
|
||||
" numb_cols = len(col_names)\n",
|
||||
" table = \"|\" + \"|\".join(col_names) + \"|\\n\"\n",
|
||||
" table += \"|\" + \"|\".join(['-' for _ in range(numb_cols)]) + \"|\\n\"\n",
|
||||
" for row in mat:\n",
|
||||
" table += \"|\" + \"|\".join([str(el) for el in row]) + \"|\\n\"\n",
|
||||
" return table"
|
||||
],
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-07-27T18:42:04.980503Z",
|
||||
"start_time": "2024-07-27T18:42:04.976703Z"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"|number of attributes|nkode length|days to crack|years to crack|\n",
|
||||
"|-|-|-|-|\n",
|
||||
"|9|4|0.02|0.0|\n",
|
||||
"|9|5|0.17|0.0|\n",
|
||||
"|9|6|1.54|0.0|\n",
|
||||
"|9|7|13.84|0.04|\n",
|
||||
"|9|8|124.56|0.34|\n",
|
||||
"|9|9|1121.01|3.07|\n",
|
||||
"|9|10|10089.08|27.64|\n",
|
||||
"|10|4|0.03|0.0|\n",
|
||||
"|10|5|0.29|0.0|\n",
|
||||
"|10|6|2.89|0.01|\n",
|
||||
"|10|7|28.94|0.08|\n",
|
||||
"|10|8|289.35|0.79|\n",
|
||||
"|10|9|2893.52|7.93|\n",
|
||||
"|10|10|28935.19|79.27|\n",
|
||||
"|11|4|0.04|0.0|\n",
|
||||
"|11|5|0.47|0.0|\n",
|
||||
"|11|6|5.13|0.01|\n",
|
||||
"|11|7|56.39|0.15|\n",
|
||||
"|11|8|620.25|1.7|\n",
|
||||
"|11|9|6822.77|18.69|\n",
|
||||
"|11|10|75050.42|205.62|\n",
|
||||
"|12|4|0.06|0.0|\n",
|
||||
"|12|5|0.72|0.0|\n",
|
||||
"|12|6|8.64|0.02|\n",
|
||||
"|12|7|103.68|0.28|\n",
|
||||
"|12|8|1244.16|3.41|\n",
|
||||
"|12|9|14929.92|40.9|\n",
|
||||
"|12|10|179159.04|490.85|\n",
|
||||
"|13|4|0.08|0.0|\n",
|
||||
"|13|5|1.07|0.0|\n",
|
||||
"|13|6|13.97|0.04|\n",
|
||||
"|13|7|181.56|0.5|\n",
|
||||
"|13|8|2360.33|6.47|\n",
|
||||
"|13|9|30684.32|84.07|\n",
|
||||
"|13|10|398896.1|1092.87|\n",
|
||||
"|14|4|0.11|0.0|\n",
|
||||
"|14|5|1.56|0.0|\n",
|
||||
"|14|6|21.79|0.06|\n",
|
||||
"|14|7|305.02|0.84|\n",
|
||||
"|14|8|4270.22|11.7|\n",
|
||||
"|14|9|59783.12|163.79|\n",
|
||||
"|14|10|836963.7|2293.05|\n",
|
||||
"|15|4|0.15|0.0|\n",
|
||||
"|15|5|2.2|0.01|\n",
|
||||
"|15|6|32.96|0.09|\n",
|
||||
"|15|7|494.38|1.35|\n",
|
||||
"|15|8|7415.77|20.32|\n",
|
||||
"|15|9|111236.57|304.76|\n",
|
||||
"|15|10|1668548.58|4571.37|\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"time_to_crack = []\n",
|
||||
"for num_attr in range(9, 16):\n",
|
||||
" for nkod_len in range(4, 11):\n",
|
||||
" hash_crack = [num_attr, nkod_len]\n",
|
||||
" hash_crack.extend(compute_time_to_crack_hash(num_attr, nkod_len))\n",
|
||||
" time_to_crack.append(hash_crack)\n",
|
||||
"\n",
|
||||
"hash_crack_md = matrix_to_md_table([\"number of attributes\", \"nkode length\", \"days to crack\", \"years to crack\"], time_to_crack)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"print(hash_crack_md)"
|
||||
],
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-07-27T18:43:31.002026Z",
|
||||
"start_time": "2024-07-27T18:43:30.997876Z"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"outputs": [],
|
||||
"source": "",
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
Reference in New Issue
Block a user