2008-04-27 06:41:01 -04:00
|
|
|
#!/usr/bin/env python
|
2008-12-06 12:07:07 -05:00
|
|
|
HAS_HASHLIB = False
|
|
|
|
try:
|
|
|
|
import hashlib
|
|
|
|
HAS_HASHLIB = True
|
|
|
|
except:
|
|
|
|
import md5
|
2008-04-27 06:41:01 -04:00
|
|
|
import cgi
|
|
|
|
|
2008-05-03 06:08:54 -04:00
|
|
|
print "Content-Type: text/plain\r\n"
|
2008-04-27 06:41:01 -04:00
|
|
|
form = cgi.FieldStorage()
|
|
|
|
if form.has_key("file"):
|
|
|
|
plik = form["file"]
|
|
|
|
length = 0
|
|
|
|
if plik.file:
|
2008-12-06 12:07:07 -05:00
|
|
|
if HAS_HASHLIB:
|
|
|
|
dig = hashlib.md5()
|
|
|
|
else:
|
|
|
|
dig = md5.new()
|
2008-04-27 06:41:01 -04:00
|
|
|
while 1:
|
|
|
|
data = plik.file.read(1000000)
|
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
length += len(data)
|
|
|
|
dig.update(data)
|
|
|
|
|
2008-05-03 06:08:54 -04:00
|
|
|
print "Filename = " + plik.filename
|
2008-04-27 06:41:01 -04:00
|
|
|
print "Size = %d" % length
|
2008-05-03 06:08:54 -04:00
|
|
|
print "MD5 = " + dig.hexdigest()
|