Hi TIM,
You may try something like following :
IMPORT XML
CONSTANT KEY_IN_BASE64_URL_SAFE = "Google Crypto Key"
CONSTANT URL_TO_SIGN = "XXX"
MAIN
DEFINE key xml.CryptoKey
DEFINE ret STRING
LET key = xml.CryptoKey.Create("
http://www.w3.org/2000/09/xmldsig#hmac-sha1")
CALL key.loadFromString(Base64Url2Base64(KEY_IN_BASE64_URL_SAFE))
LET ret = xml.Signature.signString(key,URL_TO_SIGN)
DISPLAY "Signature in base64 :",Base642Base64Url(ret)
END MAIN
# Convert Base64 safe URL to Base64 format
FUNCTION Base64Url2Base64(s)
DEFINE s STRING
DEFINE buf base.stringBuffer
LET buf = base.StringBuffer.create()
CALL buf.append(s)
CALL buf.replace("-","+",0)
CALL buf.replace("_","/",0)
CASE (s.getLength() MOD 4)
WHEN 1
RETURN NULL # ERROR (Illegal base64url string!)
WHEN 2
CALL buf.append("==")
WHEN 3
CALL buf.append("=")
END CASE
RETURN buf.toString()
END FUNCTION
# Convert Base64 to Base64 safe url format
FUNCTION Base642Base64Url(s)
DEFINE s STRING
DEFINE buf base.stringBuffer
LET buf = base.StringBuffer.create()
CALL buf.append(s)
CALL buf.replace("+","-",0)
CALL buf.replace("/","_",0)
CALL buf.replace("=",NULL,0)
RETURN buf.toString()
END FUNCTION
Notice that Genero APis loadFromString() and signString() work with base64 and not url safe base64. Therefore you need to call Base64Url2Base64() and Base642Base64Url()
Regards,
Frank