-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 06a7b01
Showing
8 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.py] | ||
indent_size = 4 | ||
|
||
[*.md] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# logs | ||
logs | ||
*.log | ||
|
||
# runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
.DS_Store | ||
|
||
# build | ||
dist | ||
build | ||
*.egg-info | ||
|
||
# editors | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Alexander Shelepenok | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# quantum-sg | ||
|
||
A command line tool that generates a cryptographically secure quantum-level secrets using ANU QRNG. | ||
|
||
## Usage | ||
|
||
This function generates a random set of secrets using the quantumrandom library. The parameters population, number and length are optional. | ||
|
||
```python | ||
from string import digits | ||
from quantum_sg import rand | ||
|
||
rand(length=24, number=2, population=digits) | ||
``` | ||
|
||
## Usage as CLI | ||
|
||
```bash | ||
$ pip install quantum-sg | ||
$ quantum-sg -l 24 -n 2 | ||
> 4HOpcSlzrP1JA5pFROUJLi7V | ||
> FkEKjlgm08Ey17HrAeeKKRl4 | ||
``` | ||
|
||
### Options | ||
|
||
This command line utility can be used to generate secure secrets of specified length and complexity. | ||
|
||
The `-h` or `--help` flag will display a help message to the user with instructions on how to use the utility. | ||
|
||
The `-n` or `--number` flag will allow the user to specify the number of secrets to generate. By default, the utility will generate one secret. | ||
|
||
The `-l` or `--length` flag will allow the user to specify the length of each generated secret. By default, this length is 24 characters. | ||
|
||
The `-wd`, `--digits`, `-wl`, `--lowercase`, `-wu`, `--uppercase`, `-wp` and `--punctuation` flags will allow the user to specify which types of characters should be included in the generated secrets. By default, digits, lowercase characters, and uppercase characters are included. | ||
|
||
## License | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Alexander Shelepenok | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import random | ||
import string | ||
|
||
import quantumrandom | ||
|
||
BLOCK_SIZE = 128 | ||
MAX_LENGTH = 1024 | ||
DEFAULT_NUMBER = 1 | ||
DEFAULT_LENGTH = 24 | ||
DEFAULT_POPULATION = string.ascii_lowercase + string.ascii_uppercase + string.digits | ||
|
||
|
||
def rand(population = DEFAULT_POPULATION, number = DEFAULT_NUMBER, length = DEFAULT_LENGTH): | ||
quantum_data = quantumrandom.get_data( | ||
data_type='hex16', | ||
block_size=BLOCK_SIZE, | ||
array_length=number, | ||
) | ||
|
||
data = [] | ||
|
||
for quantum_hex in quantum_data: | ||
random.seed(quantum_hex) | ||
data.append("".join([random.choice(population) for _ in range(length)])) | ||
|
||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import sys | ||
import string | ||
import argparse | ||
import quantum_sg | ||
|
||
BLOCK_SIZE = 128 | ||
MAX_LENGTH = 1024 | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="A command line tool that generates a cryptographically " | ||
"secure quantum-level secrets using ANU QRNG." | ||
) | ||
|
||
parser.add_argument( | ||
"-n", | ||
"--number", | ||
type=int, | ||
default=1, | ||
help="The number of secrets to be generated (default is 1)", | ||
) | ||
|
||
parser.add_argument( | ||
"-l", | ||
"--length", | ||
type=int, | ||
default=24, | ||
help="the length of each generated secret (default is 24)", | ||
) | ||
|
||
parser.add_argument( | ||
"-wd", | ||
"--digits", | ||
default=True, | ||
action=argparse.BooleanOptionalAction, | ||
help="include digits in the generated secrets (default is True)", | ||
) | ||
|
||
parser.add_argument( | ||
"-wl", | ||
"--lowercase", | ||
default=True, | ||
action=argparse.BooleanOptionalAction, | ||
help="include lowercase characters in the generated secrets (default is True)", | ||
) | ||
|
||
parser.add_argument( | ||
"-wu", | ||
"--uppercase", | ||
default=True, | ||
action=argparse.BooleanOptionalAction, | ||
help="include uppercase characters in the generated secrets (default is True)", | ||
) | ||
|
||
parser.add_argument( | ||
"-wp", | ||
"--punctuation", | ||
default=False, | ||
action=argparse.BooleanOptionalAction, | ||
help="include punctuation characters in the generated secrets (default is False)", | ||
) | ||
|
||
args = parser.parse_args() | ||
if args.length > MAX_LENGTH or args.length <= 0: | ||
sys.stdout.write(f'Length must be a non-negative integer and less than or equal to {MAX_LENGTH} \n') | ||
return | ||
|
||
population = "" | ||
|
||
if args.digits: | ||
population += string.digits | ||
|
||
if args.lowercase: | ||
population += string.ascii_lowercase | ||
|
||
if args.uppercase: | ||
population += string.ascii_uppercase | ||
|
||
if args.punctuation: | ||
population += string.punctuation | ||
|
||
for phrase in quantum_sg.rand(population=population, number=args.number, length=args.length): | ||
sys.stdout.write(phrase + "\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quantumrandom==1.9.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from setuptools import setup | ||
import os | ||
|
||
VERSION = '0.1.0' | ||
PROJECT = 'quantum-sg' | ||
AUTHOR = u'Alexander Shelepenok' | ||
AUTHOR_EMAIL = u'[email protected]' | ||
URL = 'https://github.com/alxshelepenok/quantum-sg' | ||
DESCRIPTION = "A command line tool that generates a cryptographically secure quantum-level secrets using ANU QRNG." | ||
|
||
|
||
def read_file(file_name): | ||
file_path = os.path.join( | ||
os.path.dirname(__file__), | ||
file_name | ||
) | ||
return open(file_path).read() | ||
|
||
|
||
setup( | ||
url=URL, | ||
name=PROJECT, | ||
author=AUTHOR, | ||
version=VERSION, | ||
description=DESCRIPTION, | ||
author_email=AUTHOR_EMAIL, | ||
long_description=read_file('README.md'), | ||
long_description_content_type="text/markdown", | ||
zip_safe=True, | ||
include_package_data=True, | ||
packages=['quantum_sg'], | ||
keywords='quantum random secrets', | ||
install_requires=['quantumrandom'], | ||
entry_points=""" | ||
[console_scripts] | ||
quantum-sg = quantum_sg.quantum_sg:main | ||
""", | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'License :: OSI Approved :: MIT License', | ||
'Topic :: Scientific/Engineering :: Mathematics', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
], | ||
) |