示例#1
0
 def captchaOCR(self, cUrl):
     #验证码识别接口,网上打码平台可以用100次,有时候识别不准
     timestamp = str(int(time.time()))
     uid = '110588'  #用户ID
     pdkey = '0MWzTrJX6BR90HxkYauc1BOjj1HMZ93L'  #密钥
     predict_type = '30400'
     img_data = requests.get(cUrl).content
     md5 = hashlib.md5()
     md5.update((timestamp + pdkey).encode())
     csign = md5.hexdigest()
     md5 = hashlib.md5()
     md5.update((uid + timestamp + csign).encode())
     csign = md5.hexdigest()
     # with open('abc.png','wb') as f:
     #     f.write(img_data)
     data = {
         'user_id': '110588',
         'timestamp': timestamp,
         'sign': csign,
         'app_id': '',
         'asign': '',
         'predict_type': predict_type,
         'up_type': 'mt'
     }
     file = {'img_data': ('img_data', img_data)}
     header = {
         'User-Agent': 'Mozilla/5.0',
     }
     m = requests.post('http://pred.fateadm.com/api/capreg',
                       data=data,
                       headers=header,
                       files=file)
     code = json.loads(m.text)['RspData']
     code = json.loads(code)
     return code['result']
示例#2
0
def CalcSign(pd_id, passwd, timestamp):
    md5 = hashlib.md5()
    md5.update((timestamp + passwd).encode())
    csign = md5.hexdigest()

    md5 = hashlib.md5()
    md5.update((pd_id + timestamp + csign).encode())
    csign = md5.hexdigest()
    return csign
示例#3
0
def md5(file=None):
    from hashlib import md5

    if file:
        md5 = md5()
        for chunk in file.chunks():
            md5.update(chunk)
        return md5.hexdigest()
示例#4
0
def md5_for_file(fp, block_size=2**20):
    md5 = hashlib.md5()
    while True:
        data = fp.read(block_size)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()
示例#5
0
def MD5endcoder(md5_str):
    from hashlib import md5
    md5 = md5()
    data = md5_str + Salt
    md5.update(data.encode('utf-8'))
    result = md5.hexdigest()
    print(result)
    return result
示例#6
0
def get_fptr_md5sum(fptr, block_size=2**20):
    """Processes a file md5sum 1MB at a time."""
    md5 = hashlib.md5()
    while True:
        data = fptr.read(block_size)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()
示例#7
0
def get_fptr_md5sum(fptr, block_size=2**20):
    """Processes a file md5sum 1MB at a time."""
    md5 = hashlib.md5()
    while True:
        data = fptr.read(block_size)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()
示例#8
0
def get_hash(file_name) -> Tuple:
    BUF_SIZE = 65536  # ground to 65535
    with open(file_name, "rb") as f:
        while True:
            data = f.read(BUF_SIZE)
            if not data:
                break
            md5.update(data)
            sha1.update(data)
    return (md5.hexdigest(), sha1.hexdigest())
示例#9
0
    def get_checksum(self, file_path):
        BUF_SIZE = 65536
        md5 = hashlib.md5()
        with open(file_path, 'rb') as f:
            while True:
                data = f.read(BUF_SIZE)
                if not data:
                    break
                md5.update(data)

        return md5.hexdigest()
示例#10
0
def get_sig(post):
    params = []
    for key,value in post.iteritems():
        if key == 'sig':
            continue
        if key == 'headimg':
            continue
        params.append({'key': key, 'value': value})
    params = sorted(params, key = lambda x: x['key'])
    md5 = hashlib.md5()
    string = u'&'.join(u'%s=%s'%(param['key'], param['value']) for param in params)
    string += u'&' + AireCheckConstant.API_SECRET_KEY
    #logger.warning(u"Signature Failed. string = %s" %(string))
    md5.update(string.encode('utf-8'))
    return md5.hexdigest()
示例#11
0
def getOneAttachMD5(attachment):
    try: 
        from hashlib import md5
    except ImportError:
        from md5 import md5
    md5 = md5()

    try:
        f = open(attachment, 'rb')
        for chunk in iter(lambda: f.read(8192), ''):
            md5.update(chunk)

        return md5.hexdigest()
    except Exception, e:
        print str(e)
        sys.exit()
示例#12
0
文件: pmail.py 项目: cash2one/scripts
def getOneAttachMD5(attachment):
    try:
        from hashlib import md5
    except ImportError:
        from md5 import md5
    md5 = md5()

    try:
        f = open(attachment, 'rb')
        for chunk in iter(lambda: f.read(8192), ''):
            md5.update(chunk)

        return md5.hexdigest()
    except Exception, e:
        print str(e)
        sys.exit()
示例#13
0
def _uuid(*args):
    """
    uuid courtesy of Carl Free Jr:
    (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761)
    """

    t = long(time.time() * 1000)
    r = long(random.random() * 100000000000000000L)

    try:
        a = socket.gethostbyname(socket.gethostname())
    except:
        # if we can't get a network address, just imagine one
        a = random.random() * 100000000000000000L
    data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args)
    md5 = md5()
    md5.update(data)
    data = md5.hexdigest()
    return data
示例#14
0
def _uuid( *args ):
    """
    uuid courtesy of Carl Free Jr:
    (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761)
    """

    t = long( time.time() * 1000 )
    r = long( random.random() * 100000000000000000L )

    try:
        a = socket.gethostbyname( socket.gethostname() )
    except:
        # if we can't get a network address, just imagine one
        a = random.random() * 100000000000000000L
    data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args)
    md5 = md5()
    md5.update(data)
    data = md5.hexdigest()
    return data
#!/usr/bin/env python3
#- * -coding: utf - 8 - * -

from hashlib import md5

md5 = md5()
md5.update('how to use md5 1 in '.encode('utf-8'))
md5.update('python hashlib?'.encode('utf-8'))
print(md5.hexdigest())
示例#16
0
 def __md5_id(self, content):
     from hashlib import md5
     md5 = md5()
     md5.update(content)
     return md5.hexdigest()
示例#17
0
def md5_for_data(data):
    md5 = hashlib.md5()
    md5.update(data)
    return md5.hexdigest()
示例#18
0
def CalcCardSign(cardid, cardkey, timestamp, passwd):
    md5 = hashlib.md5()
    md5.update(passwd + timestamp + cardid + cardkey)
    return md5.hexdigest()
示例#19
0
from hashlib import md5

import requests
from datetime import datetime
openid = 'JH1257c5ded253ba1ba879147372437563'
key = '2f6051d5f6eb807cfb82eb6d7da9ac08'
phoneno = '18819451571'
cardnum = '1'
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
orderid = timestamp + phoneno + cardnum
#orderid = '26536256425'
print(orderid)
url = 'http://op.juhe.cn/ofpay/mobile/onlineorder'
md5 = md5()
md5.update((openid + key + phoneno + cardnum + orderid).encode('utf-8'))
# 校验值,md5(OpenID+key+phoneno+cardnum+orderid),OpenID在个人中心查询
sign = md5.hexdigest()
# phoneno=18819451571&cardnum=1&orderid=11111111&sign=eaac475a9fe89bf96e002b4d6e0cb025&key=2f6051d5f6eb807cfb82eb6d7da9ac08
data = {
    'phoneno': phoneno,
    'cardnum': cardnum,
    'orderid': orderid,
    'sign': sign,
    'key': key
}
res = requests.post(url, data=data)
res_json = res.json()
print(res_json['error_code'])
print(res_json['reason'])
	response = conn.getresponse()
	data=response.read()
	writeLog(data)

headers = {"Content-type": "application/x-www-form-urlencoded",
            "Connection":"keep-alive"}



if(__name__=='__main__'):

	#Please type in your username and password here
	username="******" #这是用户名
	password="******" #这是密码
	password="******"+password+"12345678"
	md5=md5()
	md5.update(password)
	md5password=md5.hexdigest()+"123456781"
	conn= httplib.HTTPConnection("gw.bupt.edu.cn") 
	
	
	try:
		login(conn)
		print r'登录成功'
	except:
		print r'网络连接故障'
	'''
	logout(conn)
	'''
	conn.close() 
示例#21
0
from hashlib import md5
import sys


if len(sys.argv) == 0 or "-h" in sys.argv:
	print("Usage: md5str <string>")
else:
	md5 = md5()
	for arg in sys.argv:
		md5.update(arg)
	print md5.hexdigest()
示例#22
0
        if options.commentText != "--":
            comment = "<p>%s</p>" % options.commentText
        else:
            comment = "<p>%s</p>" % sys.stdin.read()
    elif options.commentFile:
        with open(options.commentFile, "r") as commentFile:
            commentLines = (line for line in commentFile if not line.lstrip().startswith("#"))  # delete comments
            commentLines = itertools.imap(string.strip, commentLines)                           # remove redundant whitespace
            commentLines = itertools.ifilter(None, commentLines)                                # delete blank lines 
            commentLines = (s[0].upper() + s[1:] for s in commentLines)                         # ensure first letter is capital
            commentLines = (s + ("." if s[-1] not in ".!?" else "") for s in commentLines if s) # ensure final punctuatiuon
            commentLines = ("<li>%s</li>" % line for line in commentLines)                      # add <li> tags
            comment = "\n".join(commentLines)                                                   # join lines with into single string
            comment = "<ul>\n%s\n</ul>\n" % comment                                             # surround with <ul>
    
    updateTime = datetime.now().strftime("%Y-%m-%d %H:%M")
    
    with open(htmlFile) as inFile:
        template = string.Template(inFile.read())
    
    pageText = template.safe_substitute(filename = os.path.basename(inputFile), # filename for download link
                                        md5 = md5.hexdigest(),                  # md5 hashsum of file
                                        sha1 = sha1.hexdigest(),                # sha1   "    "   "
                                        comments = comment,                     # comments, as formatted above
                                        date = updateTime)                      # last updated
    
    with open(outputFile, "w") as outFile:
        outFile.write(pageText)
        
    print "Page created!"
示例#23
0
 def save_sign(self, amount, currency, payway, shop_id):
     self.sign = md5.hexdigest(amount + ':' + currency + ':' + payway +
                               ':' + shop_id)
     save = self.save()
     return save