NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: kevin plummer on June 01, 2009, 03:17:05 AM

Title: SHA-1 hash and Base64/Base32
Post by: kevin plummer on June 01, 2009, 03:17:05 AM
I need to send an XML file to a web service. Can I use nettalk to do the following?

"You can then use the SHA-1 hash to obtain a 160bit set of characters that then need to be passed into Base64/Base32 encryption."
Title: Re: SHA-1 hash and Base64/Base32
Post by: Bruce on June 01, 2009, 05:47:08 AM
I've not done SHA-1 personally, but apparently Sean has.
Certainly it's do-able in Clarion. But it's icky, and the code we have is not really in a releaseable form.

Base64 is an "encoding" rather than an "encryption" - and yes, NetTalk has functions to do that. (Encoding and Decoding obviously.)

cheers
Bruce
Title: Re: SHA-1 hash and Base64/Base32
Post by: kevin plummer on June 01, 2009, 07:26:19 PM
No problem. What about "Canonicalisation" or C14n? I need to do this after creating the XML file but before SHA-1 and Base64.

Cheers,

Kev
Title: Re: SHA-1 hash and Base64/Base32
Post by: seancameron on June 01, 2009, 10:18:30 PM
Hi Kevin,

I've done this via a third party library, but it isn't functionality that is included in NetTalk. Are you trying to create a digital signature by any chance?

Capesoft SafeUpdate creates (and reads) standard signatures using Canonical XML, SHA-1 hashing and Base64 encoding. If that is what you are looking for then CapeSoft SafeUpdate contains all the code that you need already.

cheers,

Sean
Title: Re: SHA-1 hash and Base64/Base32
Post by: kevin plummer on June 02, 2009, 03:10:10 AM
Hi Sean,

I own Safeupdate but haven't played with it in a while.

I had a quick look a the docs but couldn't see any methods for calling C14n, SHA-1 or Base64.

I need to send P45 info to the HMRC in the UK. I've created an XML file with all the data they need and now I need to create an "IRMark" using the methods above and insert the result into the XML file before submitting the file via a webservice. I have everything working except for this IRMark.

Some notes from HMRC:
The important thing to remember is that your resulting SHA-1 hash must be in binary (160 bits long).
The SHA-1 hash can then be Base64 and Base32 encoded and the results should be printable/readable strings that can be inserted into the
XML (Base64) and displayed to the user (Base32)

So it would be great if I can use Safeupdate, I just need a little guidance

Cheers,

Kev