| 9 | |
| 10 | |
| 11 | class Otp: |
| 12 | def __init__(self, len): |
| 13 | self.len = len |
| 14 | |
| 15 | # this method generate number otp |
| 16 | @property |
| 17 | def digits(self): |
| 18 | num = 0 |
| 19 | result = [] |
| 20 | while num < self.len: |
| 21 | rand_choice = "".join(random.choices(d_char, k=self.len)[0:1]) |
| 22 | result.append(rand_choice) |
| 23 | num += 1 |
| 24 | value = "".join(result) |
| 25 | return value |
| 26 | |
| 27 | # this method generate number and capital letters otp |
| 28 | @property |
| 29 | def bd_digits(self): |
| 30 | num = 0 |
| 31 | result = [] |
| 32 | while num < self.len: |
| 33 | b_choice = "".join(random.choices(b_char, k=self.len)[0:1]) |
| 34 | d_choice = "".join(random.choices(d_char, k=self.len)[0:1]) |
| 35 | result.append(b_choice) |
| 36 | result.append(d_choice) |
| 37 | num += 1 |
| 38 | value = "".join(result[0 : self.len]) |
| 39 | return value |
| 40 | |
| 41 | # this method generate number and small letters otp |
| 42 | @property |
| 43 | def sd_digits(self): |
| 44 | num = 0 |
| 45 | result = [] |
| 46 | while num < self.len: |
| 47 | s_choice = "".join(random.choices(s_char, k=self.len)[0:1]) |
| 48 | d_choice = "".join(random.choices(d_char, k=self.len)[0:1]) |
| 49 | result.append(s_choice) |
| 50 | result.append(d_choice) |
| 51 | num += 1 |
| 52 | value = "".join(result[0 : self.len]) |
| 53 | return value |
| 54 | |
| 55 | # this method generate both small, capital letters and number otp all together |
| 56 | @property |
| 57 | def sbd_digits(self): |
| 58 | num = 0 |
| 59 | result = [] |
| 60 | while num < self.len: |
| 61 | s_choice = "".join(random.choices(s_char, k=self.len)[0:1]) |
| 62 | b_choice = "".join(random.choices(b_char, k=self.len)[0:1]) |
| 63 | d_choice = "".join(random.choices(d_char, k=self.len)[0:1]) |
| 64 | result.append(s_choice) |
| 65 | result.append(b_choice) |
| 66 | result.append(d_choice) |
| 67 | num += 1 |
| 68 | value = "".join(result[0 : self.len]) |