I am new to programming and using Access 2010 VBA. I need to apply a set of rules to an xml file so that I can access an API. I have looked at different ways of doing it but have got stuck at each one due to my limited knowledge. If anyone could point me down the right path / offer some advice for doing this that would be great.
The rules:
- Canonify an xml file to the W3C C14N specification.
- SHA1 hash the xml into binary for further encoding
- Base64 and Base32 encode the SHA1 hash
My first problem is that I can not find any way to c14n the xml in VBA. So I skipped this step as I can make sure the xml is canonicalised up front. Though ideally this would be done as part of the encoding process in case someone changes the precedent xml.
I then started looking at the SHA1 hash and found this sample code:
http://vb.wikia.com/wiki/SHA-1.bas
The problem here is that the output hash is in hexadecimal which I think I need to convert into a byte array before converting to base64. I cant find any sample code to do this.
I then came across this post: Base64 HMAC SHA1 String in VBA
This is calling the .net cyptography library for HMACSHA1 but there is a library for SHA1:
http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1.aspx
The problem here is I have no idea how calling .net library's work. I need to run this software on 10 different windows machines in the office so I need to understand it.
Lastly I found the exact function I need written in vb.net:
http://blog.kuffs.co.uk/2009/07/calculating-irmark-for-hmrc-gateway.html
Again i've got no experience with .net and am unsure how to build this into a library that is accessible to access.