def sign_data(args):
 sk = _load_key(args)
 binary_content = args.datafile.read()
 signature = sk.sign_deterministic(binary_content, hashlib.sha256)
 vk = sk.get_verifying_key()
 vk.verify(signature, binary_content, hashlib.sha256)
 if ((args.output is None) or (os.path.abspath(args.output) == os.path.abspath(args.datafile.name))):
  args.datafile.close()
  outfile = open(args.datafile.name, 'ab')
 else:
  outfile = open(args.output, 'wb')
  outfile.write(binary_content)
 outfile.write(struct.pack('I', 0))
 outfile.write(signature)
 outfile.close()
 print ('Signed %d bytes of data from %s with key %s' % (len(binary_content), args.datafile.name, args.keyfile.name))

def sign_data ( args ) : sk = _load_key ( args ) binary_content = args . datafile . read ( ) signature = sk . sign_deterministic ( binary_content , hashlib . sha256 ) vk = sk . get_verifying_key ( ) vk . verify ( signature , binary_content , hashlib . sha256 ) if ( ( args . output is None ) or ( os . path . abspath ( args . output ) == os . path . abspath ( args . datafile . name ) ) ) : args . datafile . close ( ) outfile = open ( args . datafile . name , 'ab' ) else : outfile = open ( args . output , 'wb' ) outfile . write ( binary_content ) outfile . write ( struct . pack ( 'I' , 0 ) ) outfile . write ( signature ) outfile . close ( ) print ( 'Signed %d bytes of data from %s with key %s' % ( len ( binary_content ) , args . datafile . name , args . keyfile . name ) )
sign a data file with a ecdsa private key .