EasyManua.ls Logo

Siemens SIMATIC S7 - Common Support Classes; The Encryptedstring Class

Siemens SIMATIC S7
134 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SIMATIC Automation Tool API for .NET framework
6.4 Common support classes
SIMATIC Automation Tool V2.1 user guide
Manual, V2.1.1 07/2016, A5E33042676-AC
71
6.4
Common support classes
6.4.1
The EncryptedString class
Before describing the operations available through the API, it is important to have an
understanding of some common classes that are used in most of the code examples.
The EncryptedString class
Many API operations require a legitimized connection to an S7 CPU. For these operations, a
password is required as one of the parameters to the method. The S7 CPU accepts the
password in an encrypted format. To accomplish this, the API provides the EncryptedString
class.
This class provides a way to encrypt a plain-text password that can then be used to
legitimize a CPU connection. Many of the code examples show a typical usage of this class.
Most code examples instantiate an EncryptedString directly where it is used, as follows:
Result retVal = devAsCpu.RefreshStatus(new EncryptedString("password"));
If you wish to encrypt a password to use multiple times in your code, you can also instantiate
the EncryptedString, then pass it as a parameter to multiple calls, as follows:
EncryptedString pwd = new EncryptedString("password");
DateTime curTime = new DateTime();
Result retVal = devAsCpu.RefreshStatus(pwd);
retVal = devAsCpu.GetCurrentDateTime(pwd, out curTime);
Note
If a CPU is not password protected, simply pass an empty string to the EncryptedString
constructor. For example, the following code is successful for a CPU with no protection
configu
red:
Result retVal = devAsCpu.RefreshStatus(new EncryptedString(""));
Or
Result retVal = devAsCpu.RefreshStatus(new EncryptedString(String.Empty));
The EncryptedString object does not store the user-assigned plain-text password. However,
if your application codes passwords as literal strings (i.e. new
EncryptedString("myPassword")) the plain-text "myPassword" will be compiled into the user
application, and may be visible to others using .NET reflection.

Table of Contents

Other manuals for Siemens SIMATIC S7

Related product manuals