What I want is to generate a string(key) of size 5 for my users on my website. More like a BBM PIN.
The key will contain numbers and uppercase English letters:
If you have a way of associating each user to a unique ID (for example Primary Key in Django or Flask). You can do something like this:
Note: This does not generate a fixed length.
We will pad the user_id to the right to make the generated length a bit static
import os
import base64
user_id = 1
#pad the string
number_generate = str(user_id).rjust(5,"0")
base64.b32encode(bytes(number_generate, 'utf-8')).decode('utf-8').replace('=','')