-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpassword_gen_lambda.py
More file actions
47 lines (34 loc) · 1.06 KB
/
Copy pathpassword_gen_lambda.py
File metadata and controls
47 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3
#filename: password_gen_lambda.py
#description: random password generator first attempt for lambda
length=(50-2)#20 characters
import random
# Character range function
def range_char(start, stop):
return (chr(n) for n in range(ord(start), ord(stop) + 1))
def stringToList(string):
lisRes=[]
for char in string:
lisRes.append(char)
return lisRes
def lambda_handler( event, context ):
# Example run
mylist=[]
special_list=stringToList('.!@#$^&*()')#simplied special characters
#print(str(special_list))
for character in range_char("a", "z"):
mylist.append(character)
mylist.append(character.upper())
num=random.randrange(0,9,1)
char=(special_list[num])
random.shuffle(mylist)
count=0
num_added=0
special_added=0
pass_string=""
while count<length:
pass_string=(str(pass_string) + str(mylist[count]) )
count=count+1
return pass_string=(str(num) + str(pass_string) + str(char))
pass_string=lambda_handler()
print("password is:" + pass_string)