Download:Android engineer
Android is not only able to develop apps, Android is an ecosystem, Googl does not fail, Android can not only develop apps, in the Internet of things, smart home, vehicle-mounted devices have a great future. #coding=UTF-8
XingHe Studio File to MD5 and SHA1
XingHeStudio.com
Create by Stream.Wang 2012-04-10
Modify by Stream.Wang 2012-04-10
def fil_changefileext(filename,extname=”):
FIL ChangeFileExt Changes the file name extension
TXT import OS try: if extname[0]<>'.': extname='.'+extname except: extname='' if os.path.splitext(filename)[1]=='': uouttxt=filename+'.'+extname elif os.path.splitext(filename)[1]=='.': uouttxt=filename+extname else: uouttxt=filename[:0-len(os.path.splitext(filename)[1])]+extname return uouttxtCopy the code
def fil_str2file(fstr,filename):
FIL STR2File Stores the string to a file
try:
outfile=open(filename,'w')
outfile.writelines(fstr)
outfile.close()
return True
except:
return False
Copy the code
Main program beginning # # system — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — if name = = ‘main’ : import OS, sys, math
If len (sys. Argv) = = 1: sys. Argv. Append (r ‘c: \ FreeNAS 8.0.4 – RELEASE – x64. Iso’)
if len(sys.argv)>1: filepathname=sys.argv[1] if os.path.isfile(filepathname) : Fmaxs = os.path. getSize (FilepathName)+0.00 fpos = 0.00 ppos=0 pmax=50 pjy=0 fMD5 = fil_Changefileext (filepathName,'.md5') Fsha1 =fil_changefileext(filepathname,'.sha') FFM =os.path.basename(filepathname "'+filepathname+'" ... ' import hashlib try: Umd5str = hashlib.md5() usha1str = hashlib.sha1() xFilepathName = Unicode (filepathname,'utf8') # file(xfilepathname,'rb') while True: datas = ufile.read(1024*512) if not datas: break umd5str.update( datas ) usha1str.update( datas ) fpos=fpos+1024*512 ppos=int(math.floor(fpos / fmaxs * 50)) Pposbfh =int(math.floor(fpos/fmaxs * 100)) Print '['+'*'*ppos +'='*(pmax-ppos)+'] '+ STR (pposbfh) +'%' # print '['+'*'*ppos +'] '+ STR (pposbfh) +'%' # Pjy =ppos uoutstrmd5= STR (umd5str.hexdigest()) uoutstrsha1= STR (usha1str.hexdigest()) ufile.close() print '' fil_str2file(uoutstrmd5+' *'+ffm+'\n',fmd5) fil_str2file(uoutstrsha1+' *'+ffm+'\n',fsha1) print 'Task is completed ! ' + r' [ XingHe Studio File to MD5 and SHA1 ]' except: print 'Error ! ' + r' [ XingHe Studio File to MD5 and SHA1 ]' else: print 'File "'+filepathname+'" not exist! '+ r' [ XingHe Studio File to MD5 and SHA1 ]' else: print r' [ XingHe Studio File to MD5 and SHA1 ]'Copy the code