-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.py
116 lines (105 loc) · 2.69 KB
/
generator.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import pickle,pprint,socket,webbrowser,re, random,string
import sys, os
from random import *
# Save a dictionary into a pickle file.
'''
favorite_color = { "lion": "yellow", "kitty": "red" }
strings = " !#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
pickle.dump( favorite_color, open( "save.p", "wb" ) )
pickle.dump( strings, open( "save.p", "wb" ) )
'''
def encrypt_number(inputnumber):
plainText = inputnumber
chtemp = plainText
sumnum = ""
length = len(str(plainText))
for i in range (1,length+1):
ch= chtemp%(10)
if (ch == 1):
rep = '5'
elif (ch == 2):
rep = '7'
elif (ch == 3):
rep = '2'
elif (ch == 4):
rep = '0'
elif (ch == 5):
rep = '8'
elif (ch == 6):
rep = '6'
elif (ch == 7):
rep = '1'
elif (ch == 8):
rep = '4'
elif (ch == 9):
rep = '3'
elif (ch == 0):
rep = '9'
chtemp = chtemp //(10)
sumnum += rep
Number = int(sumnum )
Reverse = 0
while(Number > 0):
Reminder = Number %10
Reverse = (Reverse *10) + Reminder
Number = Number //10
return (Reverse+3298646)
def decrypte_number(inputnumber):
plainText = inputnumber-3298646
chtemp = plainText
sumnum = ""
length = len(str(plainText))
for i in range (1,length+1):
ch= chtemp%(10)
if (ch == 5):
rep = '1'
elif (ch == 7):
rep = '2'
elif (ch == 2):
rep = '3'
elif (ch == 1):
rep = '7'
elif (ch == 8):
rep = '5'
elif (ch == 6):
rep = '6'
elif (ch == 0):
rep = '4'
elif (ch == 4):
rep = '8'
elif (ch == 3):
rep = '9'
elif (ch == 9):
rep = '0'
chtemp = chtemp //(10)
sumnum += rep
Number = int(sumnum )
Reverse = 0
while(Number > 0):
Reminder = Number %10
Reverse = (Reverse *10) + Reminder
Number = Number //10
return (Reverse)
lst = []
code=randint(10000, 9999999)
print(code)
ina = encrypt_number(code)
print(ina)
inb = decrypte_number(ina)
print(inb)
if (code == inb):
print("this is good")
for i in range (0,20):
code=randint(10000, 9999999)
print(code)
ina = encrypt_number(code)
print(ina)
inb = decrypte_number(ina)
print(inb)
if (code == inb):
print("this is good")
entery = '('+str(code)+','+str(ina)+')'
lst.append(entery)
for a in lst:
print(a)
print('')