Skip to content

Commit 7247614

Browse files
committed
Documentation work
1 parent b1d6d2e commit 7247614

4 files changed

Lines changed: 38 additions & 48 deletions

File tree

docs/index.html

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -482,41 +482,34 @@ <h2>Parts</h2>
482482
</div>
483483
</div>
484484
</div>
485-
<div class="admonition example">
486-
<p class="admonition-title">Random</p>
487-
<p>This package is expandable </p>
488-
<div class="language-py highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="kn">import</span> <span class="nn">js2pysecrets</span> <span class="k">as</span> <span class="nn">secrets</span>
489-
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a>
490-
</span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;86A8E7&quot;</span>
491-
</span><span id="__span-2-4"><a id="__codelineno-2-4" name="__codelineno-2-4" href="#__codelineno-2-4"></a>
492-
</span><span id="__span-2-5"><a id="__codelineno-2-5" name="__codelineno-2-5" href="#__codelineno-2-5"></a><span class="n">shares</span> <span class="o">=</span> <span class="n">secrets</span><span class="o">.</span><span class="n">share</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
493-
</span><span id="__span-2-6"><a id="__codelineno-2-6" name="__codelineno-2-6" href="#__codelineno-2-6"></a>
494-
</span><span id="__span-2-7"><a id="__codelineno-2-7" name="__codelineno-2-7" href="#__codelineno-2-7"></a><span class="n">recovered</span> <span class="o">=</span> <span class="n">secrets</span><span class="o">.</span><span class="n">combine</span><span class="p">(</span><span class="n">shares</span><span class="p">)</span> <span class="c1"># &#39;86a8e7&#39;</span>
495-
</span></code></pre></div>
485+
<div class="admonition danger">
486+
<p class="admonition-title">Random Data Can Be Captured</p>
487+
<div class="admonition danger">
488+
<p class="admonition-title">Random Data Can Be Captured</p>
489+
<p>Capturing the random data used to generate shares is possible. It's <strong>not</strong> enabled by default and the <code>function()</code> necessary to process the random data is at the discretion users of this package. </p>
490+
<p>The ability to access the random data is <strong>solely</strong> intended for random dithering and auditing purposes. <em>(like the images below)</em></p>
491+
</div>
496492
<div class="tabbed-set tabbed-alternate" data-tabs="2:3"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><input id="__tabbed_2_2" name="__tabbed_2" type="radio" /><input id="__tabbed_2_3" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">secrets</label><label for="__tabbed_2_2">random</label><label for="__tabbed_2_3">testRandom</label></div>
497493
<div class="tabbed-content">
498494
<div class="tabbed-block">
499495
<p><img align="left" alt="Image title" src="secrets.png" /></p>
500-
<div class="tabbed-set tabbed-alternate" data-tabs="3:1"><input checked="checked" id="__tabbed_3_1" name="__tabbed_3" type="radio" /><div class="tabbed-labels"><label for="__tabbed_3_1"> <span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"/></svg></span> Python</label></div>
501-
<div class="tabbed-content">
502-
<div class="tabbed-block">
503-
<div class="language-py highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="kn">import</span> <span class="nn">js2pysecrets</span> <span class="k">as</span> <span class="nn">secrets</span>
504-
</span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a>
505-
</span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="n">key</span> <span class="o">=</span> <span class="s2">&quot;86A8E7&quot;</span>
506-
</span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a>
507-
</span><span id="__span-3-5"><a id="__codelineno-3-5" name="__codelineno-3-5" href="#__codelineno-3-5"></a><span class="n">shares</span> <span class="o">=</span> <span class="n">secrets</span><span class="o">.</span><span class="n">share</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
508-
</span><span id="__span-3-6"><a id="__codelineno-3-6" name="__codelineno-3-6" href="#__codelineno-3-6"></a>
509-
</span><span id="__span-3-7"><a id="__codelineno-3-7" name="__codelineno-3-7" href="#__codelineno-3-7"></a><span class="n">recovered</span> <span class="o">=</span> <span class="n">secrets</span><span class="o">.</span><span class="n">combine</span><span class="p">(</span><span class="n">shares</span><span class="p">)</span> <span class="c1"># &#39;86a8e7&#39;</span>
510-
</span></code></pre></div>
511-
</div>
512-
</div>
513-
</div>
496+
<p>The <code>secrets</code> module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.</p>
497+
<p>The <code>secrets</code> <strong>should be used</strong> instead of the default pseudo-random number generator in the <code>random</code> module, which is designed for modelling and simulation, not security or cryptography.</p>
514498
</div>
515499
<div class="tabbed-block">
516500
<p><img align="left" alt="Image title" src="random.png" /></p>
501+
<div class="admonition warning">
502+
<p class="admonition-title">Warning</p>
503+
<p>The pseudo-random generators in the <code>random</code> module <strong>should not</strong> be used for security purposes. For security or cryptographic uses, use the <code>secrets</code> module. </p>
504+
</div>
517505
</div>
518506
<div class="tabbed-block">
519507
<p><img align="left" alt="Image title" src="testRandom.png" /></p>
508+
<div class="admonition warning">
509+
<p class="admonition-title">Do Not Use</p>
510+
<p><strong>For testing purposes only!</strong></p>
511+
<p>The <code>testRandom</code> function serves as useful tool for development, generating predictable values. However, when it comes to applications involving security or cryptography, it's crucial to employ a robust random number generator. </p>
512+
</div>
520513
</div>
521514
</div>
522515
</div>

docs/sitemap.xml.gz

0 Bytes
Binary file not shown.

docs_source/index.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,37 @@ $q(x) = a_0 + a_1x + \dotsi + a_{k-1}x^{k-1}$
7878
```
7979

8080

81-
!!! example "Random"
81+
!!! danger "Random Data Can Be Captured"
8282

83-
This package is expandable
83+
!!! danger "Random Data Can Be Captured"
8484

85-
``` py
86-
import js2pysecrets as secrets
87-
88-
key = "86A8E7"
89-
90-
shares = secrets.share(key, 6, 3)
85+
Capturing the random data used to generate shares is possible. It's __not__ enabled by default and the `function()` necessary to process the random data is at the discretion users of this package.
86+
87+
The ability to access the random data is __solely__ intended for random dithering and auditing purposes. _(like the images below)_
9188

92-
recovered = secrets.combine(shares) # '86a8e7'
93-
```
94-
95-
9689
=== "secrets"
9790
![Image title](secrets.png){ align=left }
9891

99-
=== " :fontawesome-brands-python: Python"
100-
``` py
101-
import js2pysecrets as secrets
102-
103-
key = "86A8E7"
92+
The `secrets` module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.
10493

105-
shares = secrets.share(key, 6, 3)
106-
107-
recovered = secrets.combine(shares) # '86a8e7'
108-
```
94+
The `secrets` __should be used__ instead of the default pseudo-random number generator in the `random` module, which is designed for modelling and simulation, not security or cryptography.
10995

11096
=== "random"
11197
![Image title](random.png){ align=left }
98+
99+
100+
101+
102+
!!! warning "Warning"
103+
104+
The pseudo-random generators in the `random` module __should not__ be used for security purposes. For security or cryptographic uses, use the `secrets` module.
112105

113106
=== "testRandom"
114107
![Image title](testRandom.png){ align=left }
115108

109+
!!! warning "Do Not Use"
116110

111+
__For testing purposes only!__
112+
113+
The `testRandom` function serves as useful tool for development, generating predictable values. However, when it comes to applications involving security or cryptography, it's crucial to employ a robust random number generator.
117114

js2pysecrets/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# settings.py
2-
import random
2+
import secrets
33
from dataclasses import dataclass, field
44
from typing import List, Optional
55

66

77
@dataclass
88
class Defaults:
9-
rng = lambda self, bits: bin(random.getrandbits(bits))[2:].zfill(bits)
9+
rng = lambda self, bits: bin(secrets.randbits(bits))[2:].zfill(bits)
1010
dithering = None
1111
bits: int = 8 # default number of bits
1212
radix: int = 16 # work with HEX by default

0 commit comments

Comments
 (0)