Hello,
thanks to your help now I have a first draft, that's better than nothing.
I'm going to show you the issue with more details:
I have a POST call to the API Gateway, with an id called MyID of 36 characters, in the body of request:
eg.
www.myl7.com/generate_token In the body of the request there is {MyID: 123456789-123456789-123456789-123456}
I have to encrypt the MyID, but the result has to be less than 100 characters.
With Base64 encoding assertion the length is ok, but it is just encoded and not encrypted.
How can I encrypt it in a string that is less than 100 carachters?
Thanks,
Alfredo
Original Message:
Sent: 07-23-2020 03:57 AM
From: Oleksij Donets
Subject: Get a short token
Hello Alfredo,
If you want to generate a new token that is less than 100 characters long, you can use the "Generate UUID" assertion or the JavaScript assertion. With the last one you can perform more flexible transformations. I have included a sample JS code for the JavaScript assertion that you can use as a basis and replace the "generateRandomString" function with your new function/s to archive your goal.
regards,
Oleks
//beginning of the JS-Code:
if (typeof context !== 'undefined') {
// this part of code is executed in GW
// the GW variable is defined
try {
var sessionId = generateRandomString();
context.setVariable('sessionId', sessionId);
} catch (err) {
context.setVariable('ErrorJS', err);
}
} else {
// for execution in a third JS tool for easiert testing
var sessionId = generateRandomString();
console.log('sessionId', sessionId);
}
function generateRandomString() {
return Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
}
Original Message:
Sent: 07-22-2020 03:28 AM
From: Alfredo Cosco
Subject: Get a short token
Hello,
how can you get a token that is less than 100 characters long?
Alternatively, is there an assertion, or a workaround, to shorten a url?
Thanks,
Alfredo