Skip to content

Commit b54b6ec

Browse files
committed
Cleaned up the code.
1 parent bd04d05 commit b54b6ec

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

js2pysecrets/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def hex2bin(hex_str):
7979
8080
The `setRNG` function mirrors the logic of the JavaScript function. If it's a
8181
string, ANY STRING, it implies a specific type is requested. In such cases,
82-
it will function like the JavaScript `test_random` RNG for testing purposes.
82+
it will function like the JavaScript `testRandom` RNG for testing purposes.
8383
8484
This adaptation aims to maintain the core functionality of the JavaScript
8585
version while adhering to Python idioms and conventions. The focus is on
@@ -239,10 +239,9 @@ def base36encode(
239239

240240
return sign + base36
241241

242-
share_id = int(share_id, 10) # Value is store as int
242+
share_id = int(share_id, 10) # Value is stored as int
243243
bits = bits or settings.bits
244244
bits_base36 = base36encode(bits).upper()
245-
# id_max = 2**bits - 1
246245
id_max = settings.maxShares
247246
id_padding_len = len(hex(int(id_max))[2:])
248247
id_hex = padLeft(hex(int(share_id))[2:], id_padding_len)
@@ -386,12 +385,13 @@ def getConfig():
386385

387386

388387
def extractShareComponents(share):
388+
389389
defaults = {
390390
"minBits": 1,
391391
"maxBits": 32,
392392
} # Assuming defaults for minBits and maxBits
393-
config = {"radix": 16} # Assuming radix as 16 for hex numbers
394393

394+
config = {"radix": 16} # Assuming radix as 16 for hex numbers
395395
bits = int(share[0], 36)
396396

397397
if not (
@@ -524,6 +524,7 @@ def hex2str(hex_string, bytes_per_char=None):
524524

525525

526526
def random(bits):
527+
527528
if not isinstance(bits, int) or bits < 2 or bits > 65536:
528529
raise ValueError(
529530
"Number of bits must be an Integer between 2 and 65536."

tests/test_zzzzzz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
# test_functions_exist.py
88

9-
import js2pysecrets.base as secrets # Import the module you want to test
9+
import js2pysecrets.base as secrets
1010

1111

12-
def test_functions_exist():
12+
def depreciated_test_functions_exist():
1313
# List of functions you expect to exist in secrets
1414
expected_functions = [
1515
"init",

0 commit comments

Comments
 (0)