crypt()

Encrypts the transferred text.

Synopsis

string crypt(string text[, isVersion = 2]);

Parameters

Parameter Meaning
string Text to be encrypted.
isVersion

Defines the format of the encrypted text:

1 = first generation hash format.

2 = second generation hash format (Default)

Important: The formats 1 and 2 are deprecated

3 = third generation hash format

Return Value

The return value is a string which consists of printable ASCII characters.

isVersion =1: returns a string with 11 characters.

  • isVersion =2: returns a string with 12 characters.
  • isVersion =3: returns a string with 61 characters.
  • In case of isVersion =1, the function always returns the same value for the same to-be encrypted text.
  • In case of isVersion =2, the function always returns the same value for the same to-be encrypted text.
  • In case of isVersion =3, the function may return different values if the same to-be encrypted text is called several times.
  • If openSSL does not exist, an alarm message appears when the function crypt(text,3) is called and a second generation hash is triggered.
  • isVersion =3 is the PKCS5 conform password hashing of the crypt function, it returns a different hash each time when the function crypt() is called, even if it is for the same string.

Description

The function crypt() encrypts the transferred text (max. 63 characters are taken into consideration) in accordance with the "Proposed Federal Information Processing Data Encryption Standard". crypt() is used in WinCC OA for encrypting passwords. Passwords are stored in the database in encrypted form and can only be read again in encrypted form. The CTRL function checkPassword() expects the unencrypted password!

main()
{
  string passw;
  passw = crypt("MYPERSONALPASSWORT",3);
  DebugN(passw);
  passw = crypt("MYPERSONALPASSWORT",2);
  DebugN(passw);
  passw = crypt("MYPERSONALPASSWORT",1);
  DebugN(passw);
}

Assignment

Miscellaneous functions

Availability

CTRL