Skip to content

Commit

Permalink
Add script for generating qrcodes (#28)
Browse files Browse the repository at this point in the history
* added script for qrcode

* Update .gitignore

* Delete pycache

Closes #27
  • Loading branch information
pxs4528 authored Aug 5, 2023
1 parent 7b68816 commit c11713d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

__pycache__/
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qrcode
29 changes: 29 additions & 0 deletions script.py
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()

0 comments on commit c11713d

Please sign in to comment.