コード例 #1
0
def do_calculation(options):
	if options.report is None:
		options.report = "report.txt"
		print "Creating file for report ({0}/{1})".format(os.getcwd(), options.report)
	hash = hashModule.get_hash(options.data)
	sign = Signature.getSignature(hash)
	sign["H"] = hash	
	ElGamalSignatureIO.writeElGamalSignature(sign, options.report, options.data)
	print "\nSignature was successful write to {0}/{1}".format(os.getcwd(), options.report)
コード例 #2
0
def do_check(options):
	readSign = ElGamalSignatureIO.readParseElGamalSignature(options.data)
	if os.path.isfile(readSign["path"]) is False:
		print "File does not exist '{0}'".format(readSign["path"])
		exit()
	if options.path is None:
		hash = hashModule.get_hash(readSign["path"])
	else:
		hash = hashModule.get_hash(options.path)
	sign = Signature.getSignature(hash)
	if readSign["H"] == hash and Signature.verificationSignature(readSign) is True:
		print "\nSignature is correct."
	else:
		print "\nSignature is incorrect."
		print "Read data"
		for x, y in readSign.items():
			if x != "path":
				print "\t{0} is {1}".format(x, format(y, "032x"))
		print "Caclulated signature"
		for x, y in sign.items():
			print "\t{0} is {1}".format(x, format(y, "032x"))