Cecil
19+ years progress programming and still learning.
Hi all.
Does anybody knows how to write a HMACSHA1 function using the SHA1-DIGEST function in the ABL???
I am using OE 10.1A and I want to write a HMACSHA1 function using the SHA1-DIGEST Function. I have seen a C++ function but I can't read C++.
Currently I am shelling out to Linux and calling a HMAC command. This work's well but I want to make the code portable accross OS Platforms without dependances.
Here is the C++ code maybe somebody is willing to help me out.
#include <hmac.h>
#include <fstream>
#include <string>
using name space std;
typedef basic_string<unsigned char> Ustring;
int main(int argc, unsigned char*argv[]){
char WBXMLchar;
Ustring WBXMLS;
ifstream inputWBXML;
//Put the PIN in a string
Ustring keyS(argv[2]);
//Open the file pointed out by "filename"
//and reads it into WBXMLS
string WBXMLfile(reinterpret_cast <char*> (argv[1]));
input WBXML.open(WBXMLfile.data(), ios::binary);
while (inputWBXML.get(WBXMLchar)){
WBXMLS +=(unsignedchar)WBXMLchar;
}
//Initialize and calculate the HMAC bytes
HMAC_CTX* hmac_ctx = new HMAC_CTX;
unsigned char md[20];
unsignedint*md_len=newunsignedint;
HMAC_Init(hmac_ctx,argv[2], keyS.length(), EVP_sha1());
unsigned char*hmac = HMAC(EVP_sha1(), argv[2],
keyS.length(), const_cast <unsignedchar*>(WBXMLS.data()),
WBXMLS.length(), md, md_len);
//hmac is the HMAC bytes to use
//Translate from binary to an ASCII string and print
intn=0;
charbuffer[41];
for(intk=0;k<20;k++){
n+=sprintf(buffer+n,"%02x",hmac[k]);
}
buffer[n+1]=0x00;
printf(buffer);
return0;
}
Does anybody knows how to write a HMACSHA1 function using the SHA1-DIGEST function in the ABL???
I am using OE 10.1A and I want to write a HMACSHA1 function using the SHA1-DIGEST Function. I have seen a C++ function but I can't read C++.
Currently I am shelling out to Linux and calling a HMAC command. This work's well but I want to make the code portable accross OS Platforms without dependances.
Here is the C++ code maybe somebody is willing to help me out.
#include <hmac.h>
#include <fstream>
#include <string>
using name space std;
typedef basic_string<unsigned char> Ustring;
int main(int argc, unsigned char*argv[]){
char WBXMLchar;
Ustring WBXMLS;
ifstream inputWBXML;
//Put the PIN in a string
Ustring keyS(argv[2]);
//Open the file pointed out by "filename"
//and reads it into WBXMLS
string WBXMLfile(reinterpret_cast <char*> (argv[1]));
input WBXML.open(WBXMLfile.data(), ios::binary);
while (inputWBXML.get(WBXMLchar)){
WBXMLS +=(unsignedchar)WBXMLchar;
}
//Initialize and calculate the HMAC bytes
HMAC_CTX* hmac_ctx = new HMAC_CTX;
unsigned char md[20];
unsignedint*md_len=newunsignedint;
HMAC_Init(hmac_ctx,argv[2], keyS.length(), EVP_sha1());
unsigned char*hmac = HMAC(EVP_sha1(), argv[2],
keyS.length(), const_cast <unsignedchar*>(WBXMLS.data()),
WBXMLS.length(), md, md_len);
//hmac is the HMAC bytes to use
//Translate from binary to an ASCII string and print
intn=0;
charbuffer[41];
for(intk=0;k<20;k++){
n+=sprintf(buffer+n,"%02x",hmac[k]);
}
buffer[n+1]=0x00;
printf(buffer);
return0;
}