Update cookies preferences
Promotic

EncryptText - method of the Pm object

Description:
The encryption of the string by the seed.
Syntax:
String EncryptText(String sText, String sSeed)
Parameters:
sText(String) Text that has to be encrypted
sSeed(String) Seed by which the text has to be encrypted (it is necessary for the text decryption). It is recommended to use 5 characters at least.
Note:
For the text decryption serves the Pm.DecryptText method.

This method is also functional in Web panels.
Example1:
The encryption of the password and writing it into the INI file:
JavaScriptVBScriptSelect and copy to clipboard

var sTxt = "Secret text";
var sTextCode = Pm.EncryptText(sTxt, "bflmpsvz");
Pm.IniFileWrite("#cfg:data.ini", "Passwords", "Password1", sTextCode);
Example2:
String encryption and decryption according to specific seed.
JavaScriptVBScriptSelect and copy to clipboard

var sTxt = "Hello";
var sTextDecrypt;
var sTextEncrypt = Pm.EncryptText(sTxt, "bflmpsvz");
Pm.Debug("TextEncrypt=" + sTextEncrypt);

sTextDecrypt = Pm.DecryptText(sTextEncrypt, "bflmpsvz");
Pm.Debug("TextDecrypt=" + sTextDecrypt);
Secure application launch by binding with a specific runtime licence number:
Specific licence number (7763) is used as a part of a seed for encrypting a text stored into a file.
JavaScriptSelect and copy to clipboard

var sTextEncrypt = Pm.EncryptText("Hello!", "bflmpsvz_7763");
Pm.FileTextWrite("#cfg:Licence.key", sTextEncrypt, "charset:utf-8;");
In the application in the onAppStartBegin event there is a script that reads the content of the file and uses the detected licence number to decrypt and compare the content.
JavaScriptSelect and copy to clipboard

var sTxt = Pm.FileTextRead("#cfg:Licence.key", 2);
var sSeed = "bflmpsvz_" + Pm.LicenceInfo(0);
var sTextDecrypt = Pm.DecryptText(sTxt, sSeed);
if (sTextDecrypt ! "Hello!")
{
Pm.MessageBox("Err", "Licence error!", 0x0);
Pm.AppStop(0);
}

History:
Pm9.00.14: Fixed bug: In the Web panel, this method did not work for some sSeed values.
Pm8.03.25: Now is functional also for JavaScript and Web panels.
Pm8.01.06: An error occured if the input text was empty string.
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- EncryptText
 
 
- Exp
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.