(PureBasic) 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.
IncludeFile "CkPrivateKey.pb"
IncludeFile "CkRsa.pb"
Procedure ChilkatExample()
success.i = 0
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
pkey.i = CkPrivateKey::ckCreate()
If pkey.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
rsa.i = CkRsa::ckCreate()
If rsa.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkRsa::ckGenKey(rsa,1024,pkey)
CkRsa::ckUsePrivateKey(rsa,pkey)
strData.s = "This is the string to be signed."
; Get the signature in base64url
CkRsa::setCkEncodingMode(rsa, "base64url")
strSig.s = CkRsa::ckSignStringENC(rsa,strData,"sha256")
Debug strSig
CkPrivateKey::ckDispose(pkey)
CkRsa::ckDispose(rsa)
ProcedureReturn
EndProcedure
|