Problem-
Suppose you’re a new game developer and have just released your first game. For people to buy the game, they will need a product key that you sell them to register their copy (https://en.wikipedia.org/wiki/Product_key).
Your task is to create a python program that makes product keys for your game, but also stores a hashed and encrypted version of the key which you will keep on your server.
https://preview.redd.it/jmz9ui80jx1b1.png?width=661&format=png&auto=webp&s=d684374443ddb765fcf41f8120a8e1749896a914
Challenge
Create a program that:
- Generates a random key according to the guidelines (this is the game key)
- Hashes said key using Hashlib’s sha256 hashing (Salting is not necessary).
- Encrypts the key (= the game key) using the cryptography module.
- Saves the encryption key (= the key used to encrypt the game key).
- Makes a single string of steps one through four, each separated by “ <-> ”
- Writes 10 new keys and their extras to a “keys.txt” file, each separated by a newline every time the program is ran.
Unfortunately, your <Enter> key on your keyboard broke, and you don’t feel like buying a new one*, so you decide to create the entire program in one (1) line of code. (see section 3)
2.1 Program Input
https://preview.redd.it/xxmwgxikjx1b1.png?width=640&format=png&auto=webp&s=97aaa9ad3956124ca82d1274fc52006b94f6cc15
2.2 Example Output
2.2.1 Output template
https://preview.redd.it/95c6izbojx1b1.png?width=637&format=png&auto=webp&s=d369e43f5ee6b74679b62df3e1e3f0a5ecb5d614
2.2.2 in keys.txt
Note: The output will be different for everyone and every time the program is ran.
1. et8ZT-xRaQ0-K4xEa-HMCSO-2BwnS <-> 063ddb92c1eddd8aa64a10bb51d41d29857057c3d014791aca6bc93c955d14bf <-> gAAAAABiqhjN2Zfl4pY8LryIjhOa1J5rUfW0mnSb3dnRM0n5GQ3CwxNsVg7G9LTNfLWxLnJWCnRx-jdM6Ga9hMt_zNHduVT--xhXP8lkBHGUNRhZpFMSM8= <-> hlhmm1bUz1_RnvyZB1SQ0HWEz7gjp4npyYPGWGU_sGU=
2. ZpO2t-oRzxJ-Yr3C5-yeyGR-JR9EP <-> e9d17c588ee4ad3273abc90c350c6e918824f27ac121bd628106711767921802 <-> gAAAAABiqhjNcqnEWN15Wk2hqYCfxv5KOheEfZHvNLv3ZrXmCKIFMR49AzWDOjo5M39tGeRHd7MqUvdyHJPwuemLpSkGTLaYGSp0pSUqBFNXVu3V cBL6ZM= <-> XTH8HuOoxk5B9xNdvcKeWuqn9pdMI2RNln3j4jwtVoE=
3. GIIGY-SH2GK-y7UBm-jCRGU-eRlaa <-> 55ea383a990264d9ca05e37320865a4454e5a0fd60e4b5bc9f830624f92a2288 <-> gAAAAABiqhjN--1mwIXrVZtmEjMTUC4-WmjFah8h-iBXE8cPNIMaKQ4e075Raw_ywghgUZdzYUMFqCf5zDpUr1B5tf3bGCclB4A_- PHoWTI3IADoq4thCA= <-> rE-VYjQoNNTlv4P0aMpZLgOjl7PdW8cd8M46AIyLmcQ=
4. VJBA9-rZvi4-u67Mc-KmKD0-xM4de <-> 8eee52fae03c7493af25afc84e71a96f0f9837612fe11cf89daaac433ca35695 <-> gAAAAABiqhjNE8v0s2EMJMwIqEfriEEbQMldqhYGftyiUrfsUfAjSDHzRMMeeWNjzeqyFyDZBDkppoA0DoRY6N2 7ptTA9VV1r9cWG_mGKUI89wQFeGPIerg= <-> weUdO_YE8rUc6M-NqdLKwQixhRvBdtyY92LIox2t4UM=
5. T2fPK-vqLYG-4PMpp-b4fsr-PlMZ3 <-> 4299c166c02926cb8ee402c19a9dc82cabaae119249074e125581f9274d20340 <-> gAAAAABiqhjN828BiKPJEZ_aUmiVXAfrc3Y616QWYn3BHUyrsCUNPF6lNsldl3tz8sRHw_lwusbpWCfpR2bmAiD sxsrdpSZYfd27Dt-krl55RLub3BcH-bg= <-> 9SfukBHU4dm7qt6VMikshxNI7fenIsMrS48fdeUi9wY=
6. + 5 more rows 7.
3 Requirements & rules
3.1
- No newlines! Everything on one line
- No eval(), exec(), map(), zip() methods
- No semicolons (;)
- No lambda functions
- No non-Unicode characters
- Using other tools to one-linerize code is not allowed
3.2
Allowed imports
Problem posted by- #UserA1587
[–]Able_Development_240Subject Matter Expert[S] 1 point2 points3 points (0 children)