The Crypt component is used to en- or decrypt a string with a given key or to create a hash of it.
crp = app.CreateCrypt(
options )
→
app object: Crypt
Example - Basic
function OnStart()
{
text = "Hello World!";
crpt = app.CreateCrypt();
var encr = crpt.Encrypt(text, "key");
var decr = crpt.Decrypt(encr, "key");
var hash = crpt.Hash(text);
app.Alert(
'text: "' + text + '"\n' +
'encr: "' + encr + '"\n' +
'decr: "' + decr + '"\n' +
'hash: "' + hash + '"\n' ,
"Data"
);
}
Example - Encrypt using device id
function OnStart()
{
crp = app.CreateCrypt();
ShowDialog( "Hello World" );
}
function ShowDialog( data )
{
app.ShowTextDialog("input text", data, OnText);
}
function OnText( text )
{
var dlg = app.CreateYesNoDialog( "Choose option", "NoCancel" );
dlg.SetOnTouch( OnAction );
dlg.data.text = text;
dlg.Show();
dlg.SetButtonText( "Encrypt", "Decrypt" );
}
function OnAction( result )
{
if( result == "Yes" )
{
result = crp.Encrypt( this.data.text, app.GetDeviceId() );
ShowDialog( result );
}
else if( result == "No" )
{
result = crp.Decrypt( this.data.text, app.GetDeviceId() );
ShowDialog( result );
}
}
Methods
The following methods are available on the Crypt object:
String
String: comma “,” separated
String: “MD5” or “SHA” or “SHA-1” or “SHA-224” or “SHA-256” or “SHA-384” or “SHA-512”
String: “Wrap”
crp.Batch
Batch method calls to be able to set all object's properties at once.
Note that you need to specify each parameter (use “” or null to leave some out)
Inherited methods can be called by appending an underscore to the function name (ie. txt.Batch({ SetBackColor_: [“red”] })
crp.Decrypt
Decrypt text with a key.
crp.Encrypt
Encrypt text with a key.
crp.GetType
Returns the control class name.
crp.Hash
Build a hash of a string for one-way encryption.
crp.SetDescription
Set a control description for accessibility