Asanka,

I assume you want to do the encode using OpenSSL?

There is some stuff in the OpenSSL interface for Base64 in xsec that might provide some pointers.

http://cvs.apache.org/viewcvs.cgi/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoBase64.cpp?rev=1.7&view=markup

If you want to do it using xsec, there are examples in DSIGReference for doing it using xsec calls (setHash)

http://cvs.apache.org/viewcvs.cgi/xml-security/c/src/dsig/DSIGReference.cpp?rev=1.23&view=markup

Cheers,
        Berin


Asanka Priyanjitih wrote:

Hi Team





I wrote a piece of code to generate a password digest. But this is not complete one. After generating SHA-1 hash, we have to encode SHA-1 hash to Base64.If some one knows how can we do that using that libraries or some other suitable method please tell me?



This is that my code



#include <openssl/sha.h>



#include <stdio.h>

#include <string.h>

#include <memory.h>

.

.

.

.

.



char* doPasswordDigest(char *nonce,char *created,char *passwordin)

{

      char* passwordout=NULL;

      int para_size=0;

      char* para_cat=NULL;

      char* md_return=NULL;



      /*para_cat==nonce + created + password*/



      para_size=strlen(nonce)+strlen(created)+strlen(passwordin);

      para_cat=(char*)malloc(para_size);

      strcpy(para_cat,nonce);

      strcat(para_cat,created);

      strcat(para_cat,passwordin);





/*SHA1(para_cat,para_size,passwordwout)==SHA-1 ( nonce + created + password ) */



passwordout = (unsigned char*)malloc(20);

SHA1((const unsigned char*)para_cat,para_size,(unsigned char*)passwordout);



.

.

/* I want to encode passwordout to Base64*/

.

.

.

.





      free(para_cat);

      free(passwordout);



      .

.

}









Thanks & Regards





G J Asanka Priyanjith











------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
This message, including any attachments, contains confidential information intended for a specific individual and purpose, and is intended for the addressee only. Any unauthorized disclosure, use, dissemination, copying, or distribution of this message or any of its attachments or the information contained in this e-mail, or the taking of any action based on it, is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return e-mail and delete this message.


Reply via email to