Forum Discussion
Ensuring a Random Number is not Re-picked
Hi Kevin,
If you don't need anything so custom, and could get by with a type of "masking" approach, I Googled a simple JavaScript encryption method (found here) that converts your string into Base64 and back.
For my test In Storyline, I created 3 text variables (baseString, encodedString, and decodedString).
On the stage, I created a text entry field (the default TextEntry 1 variable changed to the baseString variable).
Then added 2 buttons (one to encrypt and one to decrypt) with JavaScript triggers that will convert the entered text and display in two additional text fields displaying the other 2 variables (encodedString, and decodedString).
On the encrypt button, I added this JavaScript to the trigger:
var player = GetPlayer();
//The baseString variable could be populated by retrieving the learner name from the LMS, but just used text entry here.
var baseString = player.GetVar("baseString");
//Convert to base64
var encodedString = window.btoa( baseString );
//Display in text field, but this could be sent to your Google sheet.
player.SetVar("encodedString", encodedString);
On the decrypt button, it goes the other way:
var player = GetPlayer();
//Grab the encoded text
var encodedString = player.GetVar("encodedString");
//Convert back to normal text
var decodedString = window.atob( encodedString );
//Display in the text field
player.SetVar("decodedString", decodedString);
The test file is attached.
Hope that helps.