(Unicode C) Base64url Encoding
Base64url encoding is identical to base64 encoding except it uses non-reserved URL characters (e.g. '–' is used instead of '+', and '_' is used instead of '/') and it omits the padding characters. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkPrivateKeyW.h>
#include <C_CkRsaW.h>
void ChilkatSample(void)
{
BOOL success;
HCkPrivateKeyW pkey;
HCkRsaW rsa;
const wchar_t *strData;
const wchar_t *strSig;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
pkey = CkPrivateKeyW_Create();
rsa = CkRsaW_Create();
CkRsaW_GenKey(rsa,1024,pkey);
CkRsaW_UsePrivateKey(rsa,pkey);
strData = L"This is the string to be signed.";
// Get the signature in base64url
CkRsaW_putEncodingMode(rsa,L"base64url");
strSig = CkRsaW_signStringENC(rsa,strData,L"sha256");
wprintf(L"%s\n",strSig);
CkPrivateKeyW_Dispose(pkey);
CkRsaW_Dispose(rsa);
}
|