-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for generating qrcodes (#28)
* added script for qrcode * Update .gitignore * Delete pycache Closes #27
- Loading branch information
Showing
3 changed files
with
32 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 |
---|---|---|
|
@@ -34,3 +34,5 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
__pycache__/ |
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 @@ | ||
qrcode |
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,29 @@ | ||
import qrcode | ||
import os | ||
|
||
def generate_qr_code(data, filename): | ||
qr = qrcode.QRCode( | ||
version=1, | ||
error_correction=qrcode.constants.ERROR_CORRECT_L, | ||
box_size=10, | ||
border=4, | ||
) | ||
qr.add_data(data) | ||
qr.make(fit=True) | ||
img = qr.make_image(fill_color="black", back_color="white") | ||
img.save(filename) | ||
|
||
def main(): | ||
output_directory = "qr_codes" | ||
if not os.path.exists(output_directory): | ||
os.makedirs(output_directory) | ||
|
||
for msd in ['A', 'B', 'C', 'D']: | ||
for lsd in range(0x7E): # 0x7E = 126 in decimal | ||
hex_num = format(lsd, '02X') | ||
data = f'hackuta2023:{msd}{hex_num}' | ||
filename = os.path.join(output_directory, f'qr_{msd}_{hex_num}.png') | ||
generate_qr_code(data, filename) | ||
|
||
if __name__ == "__main__": | ||
main() |