senol-randomizer 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- senol_randomizer/__init__.py +32 -0
- senol_randomizer/core.py +91 -0
- senol_randomizer/senol_bool.py +8 -0
- senol_randomizer/senol_byte.py +18 -0
- senol_randomizer/senol_float.py +6 -0
- senol_randomizer/senol_integer.py +8 -0
- senol_randomizer/senol_string.py +48 -0
- senol_randomizer-0.1.3.dist-info/METADATA +24 -0
- senol_randomizer-0.1.3.dist-info/RECORD +11 -0
- senol_randomizer-0.1.3.dist-info/WHEEL +5 -0
- senol_randomizer-0.1.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from .senol_integer import createint as newint
|
|
2
|
+
from .senol_string import createstr as newstr
|
|
3
|
+
from .senol_float import createfloat as newfloat
|
|
4
|
+
from .senol_bool import createbool as newbool
|
|
5
|
+
from .senol_byte import createbyte as newbyte
|
|
6
|
+
from .core import RNG
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.3"
|
|
10
|
+
|
|
11
|
+
def signature(show=False):
|
|
12
|
+
data = (
|
|
13
|
+
f"senol_randomizer v{__version__}\n"
|
|
14
|
+
"Experimental Toolkit\n"
|
|
15
|
+
"Author: Batuhan Şenol\n"
|
|
16
|
+
"-- Batuhan Şenol"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if show:
|
|
20
|
+
print(data)
|
|
21
|
+
|
|
22
|
+
return data
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"createint",
|
|
26
|
+
"createstr",
|
|
27
|
+
"createfloat",
|
|
28
|
+
"createbool",
|
|
29
|
+
"createbyte",
|
|
30
|
+
"RNG",
|
|
31
|
+
"signature"
|
|
32
|
+
]
|
senol_randomizer/core.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import gmpy2 as m
|
|
2
|
+
from gmpy2 import mpz
|
|
3
|
+
import os as o
|
|
4
|
+
import time as t #test amaçlı
|
|
5
|
+
|
|
6
|
+
n = [
|
|
7
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820063),
|
|
8
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820109),
|
|
9
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820243),
|
|
10
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820301),
|
|
11
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820411),
|
|
12
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820459),
|
|
13
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820507),
|
|
14
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820579),
|
|
15
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564820789),
|
|
16
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821041),
|
|
17
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821077),
|
|
18
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821099),
|
|
19
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821123),
|
|
20
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821209),
|
|
21
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821237),
|
|
22
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821239),
|
|
23
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821503),
|
|
24
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821593),
|
|
25
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821629),
|
|
26
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564821687),
|
|
27
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564822673),
|
|
28
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564822787),
|
|
29
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564822887),
|
|
30
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564823193),
|
|
31
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564823853),
|
|
32
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564823889),
|
|
33
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564824221),
|
|
34
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564824323),
|
|
35
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564824597),
|
|
36
|
+
mpz(57896044618658097711785492504343953926634992332820282019728792003956564824761)
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
SOURCE_MAX = mpz(2**256)
|
|
40
|
+
|
|
41
|
+
def compress(x: mpz, a: int, b: int) -> int:
|
|
42
|
+
if a > b:
|
|
43
|
+
raise ValueError(f"a: ({a}) > b: ({b})")
|
|
44
|
+
if a == b:
|
|
45
|
+
return a
|
|
46
|
+
|
|
47
|
+
span = mpz(b - a + 1)
|
|
48
|
+
limit = SOURCE_MAX - (SOURCE_MAX % span)
|
|
49
|
+
|
|
50
|
+
while x >= limit:
|
|
51
|
+
x = mpz(int.from_bytes(o.urandom(32), 'big'))
|
|
52
|
+
|
|
53
|
+
return int(a + (x % span))
|
|
54
|
+
|
|
55
|
+
def ms(func, *args):
|
|
56
|
+
start = t.perf_counter_ns()
|
|
57
|
+
r = func(*args)
|
|
58
|
+
end = t.perf_counter_ns()
|
|
59
|
+
print(f"{(end-start)/1000000} ms")
|
|
60
|
+
return r
|
|
61
|
+
|
|
62
|
+
def _256bit():
|
|
63
|
+
return int.from_bytes(o.urandom(32), "big")
|
|
64
|
+
|
|
65
|
+
def RNG():
|
|
66
|
+
|
|
67
|
+
x = _256bit()
|
|
68
|
+
|
|
69
|
+
for i in n:
|
|
70
|
+
|
|
71
|
+
y = _256bit()
|
|
72
|
+
x = m.powmod(x, y, i)
|
|
73
|
+
|
|
74
|
+
return x
|
|
75
|
+
|
|
76
|
+
def logic(a: bytes, b: bytes, c: bytes) -> bytes:
|
|
77
|
+
result = bytearray()
|
|
78
|
+
prev = 0x5A
|
|
79
|
+
|
|
80
|
+
for pa, pb, pc in zip(a, b, c):
|
|
81
|
+
t1 = (pa & pb) ^ (pb | pc) ^ (pa & pc)
|
|
82
|
+
t2 = t1 ^ pa ^ pb ^ pc
|
|
83
|
+
t3 = t2 ^ prev
|
|
84
|
+
out = ((t3 << 3) | (t3 >> 5)) & 0xFF
|
|
85
|
+
result.append(out)
|
|
86
|
+
prev = out
|
|
87
|
+
|
|
88
|
+
return bytes(result)
|
|
89
|
+
|
|
90
|
+
def rbyte(n):
|
|
91
|
+
return o.urandom(n)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from .core import ms, RNG, compress
|
|
2
|
+
import string as s
|
|
3
|
+
import gmpy2 as g
|
|
4
|
+
|
|
5
|
+
alp = list(s.ascii_letters + s.digits)
|
|
6
|
+
|
|
7
|
+
def createstr(
|
|
8
|
+
|
|
9
|
+
_min: int = 32,
|
|
10
|
+
_max: int = 122,
|
|
11
|
+
num: int = 10,
|
|
12
|
+
|
|
13
|
+
charsandnumbers: bool = False
|
|
14
|
+
|
|
15
|
+
):
|
|
16
|
+
|
|
17
|
+
if charsandnumbers == True:
|
|
18
|
+
|
|
19
|
+
nums = []
|
|
20
|
+
data = []
|
|
21
|
+
|
|
22
|
+
for _ in range(num):
|
|
23
|
+
nums.append(g.mpz(RNG()))
|
|
24
|
+
|
|
25
|
+
for i in nums:
|
|
26
|
+
data.append(alp[g.mod(i, len(alp))])
|
|
27
|
+
|
|
28
|
+
return ''.join(data)
|
|
29
|
+
|
|
30
|
+
else:
|
|
31
|
+
|
|
32
|
+
nums = []
|
|
33
|
+
data = []
|
|
34
|
+
|
|
35
|
+
for _ in range(num):
|
|
36
|
+
nums.append(g.mpz(RNG()))
|
|
37
|
+
|
|
38
|
+
for i in nums:
|
|
39
|
+
data.append(chr(compress(x=i, a=_min, b=_max)))
|
|
40
|
+
|
|
41
|
+
return ''.join(data)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: senol-randomizer
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Cryptography-inspired random generation experiment
|
|
5
|
+
Author: Batuhan Şenol
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: random,cryptography,rng,number-generation,random-data
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Security :: Cryptography
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: gmpy2
|
|
20
|
+
|
|
21
|
+
This library is a cryptographic random generation experiment.
|
|
22
|
+
|
|
23
|
+
Its security properties have not been formally analyzed or verified.
|
|
24
|
+
It is not recommended for production or security-critical applications.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
senol_randomizer/__init__.py,sha256=YxoNW-jEj0x4BWsAjv29miJTbx5KxLxT8S1X65v_sjg,653
|
|
2
|
+
senol_randomizer/core.py,sha256=fuSwWeihUJnydhDB5zajRAC_pfwBHXPgKwJRQQSj6d8,3807
|
|
3
|
+
senol_randomizer/senol_bool.py,sha256=NFdsoPy_GwQry6vxOSalZVX5M-4oHuZmOxeUk0W3T9w,118
|
|
4
|
+
senol_randomizer/senol_byte.py,sha256=_L2GAPY8hZZcml158aclzOM8LnJIv3S0qEJhnTLeEao,254
|
|
5
|
+
senol_randomizer/senol_float.py,sha256=liXzhu0ePsDGVad-1QVNYmcp7viNlgyleKGtxkwxDCU,221
|
|
6
|
+
senol_randomizer/senol_integer.py,sha256=xAgwM4O5bqXKsieR9__AfEax21Jo0THMwvsFiTCzBe0,163
|
|
7
|
+
senol_randomizer/senol_string.py,sha256=UMRif1G8Bmd_6bVQSpGSz16NTRjp_P46e7wBX0dG26A,767
|
|
8
|
+
senol_randomizer-0.1.3.dist-info/METADATA,sha256=qu0Fd1B8aTvy7jxWt-aSkT_XVnMMo79v-Px6xxjbVe8,952
|
|
9
|
+
senol_randomizer-0.1.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
10
|
+
senol_randomizer-0.1.3.dist-info/top_level.txt,sha256=FSEIi1SqFkkv_5yd8mvo17glKLyR_Qm8GjVnuVPO-FA,17
|
|
11
|
+
senol_randomizer-0.1.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
senol_randomizer
|