Hash ,signature and verify: hashlib.sha256

Post your tools and samples or ask for them.
Riuks
Estonia
Posts: 6
Joined: 10 Mar 2017, 07:41
Location: Tallinn, Estonia

Hash ,signature and verify: hashlib.sha256

Post by Riuks » 17 Jul 2018, 10:41

Hi
Im looking for sha256 crypto sample :
does enyone have done something in Team Developer?

############################################################################
test.key - private key
test.pem -public key from certificate
############################################################################
======== to generate e-invoice hashi to service(service:ForwardInvoice) ============
input= u"%s#%s#%s#%s" % (
provider_code,
transfer_datetime.strftime('%d.%m.%Y %H:%M:%S'),
invoice_xml_file,
invoice_pdf_file,
)
input_hash = hashlib.sha256(input).digest()


========= signing hash with phyton ============
rsa = M2Crypto.RSA.load_key("test.key")
gen_sig = rsa.private_encrypt(input_hash, M2Crypto.RSA.pkcs1_padding)
sig = base64.encodestring(gen_sig)

========= generate sining from hash with openssl ============
openssl rsautl -sign -in rasi.txt -inkey test.key
output -> base64-encoded.

========= verifing signature with openssl ============
openssl rsautl -verify -certin -inkey test.pem -in input.txt
where input.txt is base-64-decoded sign.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1114
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Hash ,signature and verify: hashlib.sha256

Post by Dave Rabelink » 17 Jul 2018, 10:52

Have you checked this thread?


viewtopic.php?f=6&t=45799
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “Tools & Samples”

Who is online

Users browsing this forum: [Ccbot] and 0 guests