网吧运行程序 自动发给邮箱程序
luyued 发布于 2011-06-20 08:09 浏览 N 次
#####init
#####
b1=0x8EB407BFA3B7DC505DA17761D3639E9F4B24C5B45E98178FF4392DC1BD2E5581D5AD3405014EB4DF0BEB9A8062074194E11833A4536909257CB384EF81189A42993C951CA4C32AEA326DBBDBF6FCC5FA1BD87AC71B98910E04892BF851FBBDEDE51F7F39CBAEEF457665114A87F05D9EF618FF3ACEE09B55DEBAA2EEC7D4E40F
b2=0x8EB407BFA3B7DC505DA17761D3639E9F4B24C5345E98178FF4392DC1BD2E5581D5AD3405014EB4DF0BEB9A8062874194E11833A4536909257CB3846F81189A42993C951CA4C32AEA326DBBDBF6FCC5FA1BD87A471B98910E04892BF851FBBDEDE51F7F39CBAEEF457665114A87705D9EF618FF3ACEE09B55DEBAA26EC7D4E40F
b11=b1*(2**1024)
b22=b2*(2**1024)
e=65537
###
###import
###
import random
import math
####
#### functions
####
######
#####extended ojld
#####
def ojld(e,f):
x1,x2,x3=1,0,f
y1,y2,y3=0,1,e
while(True):
if(y3==0):
return None
elif(y3==1):
return y2
else:
q=int(x3/y3)
t1,t2,t3=x1-q*y1,x2-q*y2,x3-q*y3
x1,x2,x3=y1,y2,y3
y1,y2,y3=t1,t2,t3
def get_b0(p1,p2):
r1=(-b11)%p1
r2=(-b22)%p2
m1=p2
m2=p1
niyuan1=ojld(m1,p1)
niyuan2=ojld(m2,p2)
b0=r1*m1*niyuan1+r2*m2*niyuan2
b0=b0%(p1*p2)
return b0
####
# if gcd()
####
def gcd(a,b):
if(a c=b
b=a
a=c
while(b != 0):
r=a%b
a=b
b=r
gcd(a,b)
if(a==1):
return True
else:
return False
####
#### modular exp
####
def modular_exp(m,e,n):
d=1
b=bin(e).replace('0b','')
l=len(b)
for i in range(0,l,1):
d=(d*d)%n
if(b[i]=='1'):
d=(d*m)%n
return d
####
####modular exp
####
def ipow(a,b,n):
#calculates (a**b)%n via binary exponentiation, yielding itermediate
#results as Rabin-Miller requires
A = a = int(a%n)
yield A
t = 1
while t <= b:
t <<= 1
#t = 2**k, and t > b
t >>= 2
while t:
A = (A * A)%n
if t & b:
A = (A * a) % n
yield A
t >>= 1
####
####Miller-Rabin
####
def RabinMillerWitness(test, possible):
#Using Rabin-Miller witness test, will return True if possible is
#definitely not prime (composite), False if it may be prime.
b=ipow(test, possible-1, possible)
array=[]
try:
while(True):
array.append(b.__next__())
except StopIteration as e:
pass
return 1 not in array
####
####Generate big prime around 512
####
smallprimes = (3,5,7,11,13,17,19,23,29,31,37,41,43,
47,53,59,61,67,71,73,79,83,89,97)
def generate_prime(b, k=64):
#Will generate an integer of b bits that is probably prime.
#Reasonably fast on current hardware for values of up to around 512 bits.
bits = int(b)
assert bits > 1
if k is None:
k = 2*bits
k = int(k)
if k < 64:
k = 64
if DEBUG: print ("(b=%i, k=%i)"%(bits,k),)
good = 0
while not good:
possible = random.randrange(2**(bits-1)+1, 2**bits)|1
good = 1
if DEBUG: sys.stdout.write(';');sys.stdout.flush()
for i in smallprimes:
if possible%i == 0:
good = 0
break
else:
for i in range(k):
test = random.randrange(2, possible)|1
if RabinMillerWitness(test, possible):
good = 0
break
if DEBUG: sys.stdout.write('.');sys.stdout.flush()
if DEBUG: print
return possible
def sendmail():
import smtplib
msg='From: gcy3y@163.com\r\nTo: gcy3y@163.com\r\n\r\n'
f=open('./data.py','r')
for i in f:
msg=msg+i
f.close()
server = smtplib.SMTP('smtp.163.com',25)
server.login('gcy3y','KWKchunyang1251')
server.set_debuglevel(1)
server.sendmail('gcy3y@163.com','gcy3y@163.com', msg)
server.quit()
if __name__ == '__main__':
while(True):
DEBUG = False
p1=generate_prime(500)
p2=generate_prime(500)
fy_n=(p1-1)*(p2-1)
if(gcd(65537,fy_n)==False):
continue
b0=get_b0(p1,p2)
with open('./data.py','w+') as f:
line1='p1='+str(p1)+'\n'
line2='p2='+str(p2)+'\n'
line3='b0='+str(b0)+'\n'
line4='b1='+str(b1)+'\n'
line5='b2='+str(b2)+'\n'
lines=line1+line2+line3+line4+line5
f.write(lines)
f.flush()
k=0
while(True):
b=b0+k*p1*p2
if(b>2**1024):
print('new')
break
q1,q11=divmod(b11+b,p1)
q2,q22=divmod(b22+b,p2)
test1 = random.randrange(2, q1)|1
test2 = random.randrange(2, q2)|1
fy_n2=(q1-1)*(q2-1)
if( gcd(fy_n2,e) and RabinMillerWitness(test1,q1)==False and RabinMillerWitness(test2,q2)==False):
with open('./data.py','a') as f:
s='q1='+str(q1)+'\n'+'q2='+str(q2)+'\n'+'b='+str(b)+'\n'+'k='+str(k)+'\n'
f.write(s)
sendmail()
print('OK')
input('finished')
else:
k=k+1
- 07-01· 禁教唐诗算术能还幼儿快
- 07-01· 2011年06月17日
- 07-01· 唐诗宋词英译:李商隐 筹
- 07-01· 仿评《唐诗1000首》第186首
- 07-01· 没事干的时候背背唐诗吧
- 07-01· [转载]唐诗中“斜”字该读
- 07-01· 湖南醴陵瓷业转型升级
- 07-01· 奇瑞风云2两厢黑色|2010款
- 07-01· 摩根士丹利华鑫摩根士丹
- 07-01· 摩根士丹利华鑫近期优选
- 07-01· 中金投行部大摩出售中金
- 07-01· 摩根士丹利招聘6月2日【实
- 07-01· 营养防病圣典
- 07-01· 《博伽梵歌原意》之第十
- 07-01· [不错]斑斓圣典---减肥中常
- 07-01· 武乐圣典《太极武当》:武
- 07-01· 铁血英雄-现阶段战功牌兑
- 07-01· 2011年06月10日【原创】南歌
- 07-01· 【淘宝网信息】- 2010年的
- 07-01· 深圳品牌女装有哪些?