#!/usr/bin/env python
# coding: utf-8
# # secrets.randbelow(n): This function returns a random integer in the range [0, n)
# In[1]:
import secrets
passwd = secrets.randbelow(100)
print(passwd)
# # secrets.randbits(k): This function returns an int with k random bits
# In[2]:
import secrets
passwd=secrets.randbits(4)
print(passwd)
# # Generate a ten-character alphanumeric password.
# In[3]:
#clcoding.com
import secrets
import string
alphabet = string.ascii_letters + string.digits
password = ''.join(secrets.choice(alphabet) for i in range(10))
print(password)
# # Generate a ten-character alphanumeric password with at least one lowercase character, at least one uppercase character, and at least three digits.
# In[4]:
#clcoding.com
import secrets
import string
alphabet = string.ascii_letters + string.digits
while True:
password = ''.join(secrets.choice(alphabet) for i in range(10))
if (any(c.islower() for c in password) and any(c.isupper()
for c in password) and sum(c.isdigit() for c in password) >= 3):
print(password)
break
# In[ ]:
0 Comments:
Post a Comment