Protect a component during import

Protect components during importing using code.
  • To protect a component during importing so the end user cannot view the source code, specify either the
    SourceKey
    or
    EncodedSourceKey
    attribute.
  • To protect a component from change, but allow the end user to view the source code, also specify the
    SourceProtectionType
    attribute.
Routines are used in these examples:
The SourceKey Attribute
The value of the SourceKey attribute is a text string which is a plain text representation of the source key for the component. For example, to protect a routine:
ROUTINE MyToBeProtectedRoutine (Description := " Desc.text", SourceKey := " MyKey")
END_ROUTINE
The EncodedSourceKey Attribute
The value of the EncodedSourceKey attribute is a base 64 representation of the encoded source key. This representation is produced by the
Logix Designer
application in the export file when protected components are exported in an unencoded format.
For example, to protect a routine using an EncodedSourceKey attribute:
ROUTINE MyToBeProtectedRoutine (Description:=" Desc.text",
EncodedSourceKey := " gQCuAA0A2gDGAKEAfgB6AFEAHiAoAM0AOQAZINAAOSBTAJ0AYwAJAGUA0gCjAG8AKgAtAMQAfgFVAOAAzQBnAFQAxwDXAPUAtgAGAMwAWwA",)
END_ROUTINE
The SourceProtectionType Attribute
To protect a component from change but allow the end user to view the source code, specify the SourceProtectionType attribute, in addition to the SourceKey or EncodedSourceKey attribute. A value of 1 indicates that the protected component is viewable. For example, to both protect a routine and make its source viewable to the end user:
ROUTINE MyToBeProtectedRoutine (Description:=" Desc.text",
SourceKey := " MyKey",
SourceProtectionType := 1
)
END_ROUTINE
LX5 Format
The SourceKey, EncodedSourceKey and SourceProtectionType attributes are also available in L5X format, however the SourceProtectionType attribute supports “Viewable” and “Full Protection”.
For example, protect a routine and prevent the user from viewing the source by setting its source key. The examples shown specify either the SourceKey or the EncodedSourceKey:
<Routine Name=" MyToBeProtectedRoutine" Type="RLL" SourceKey="MyKey">
or
<Routine Name=" MyToBeProtectedRoutine" Type="RLL" EncodedSourceKey=" CYARQ8c7nw4+PE9J6+goLDeCWB34Fz5K0s9Fc3Mz4JnIkmATTletANAADExXoQ5+" />
Alternatively, explicitly set the SourceProtectionType:
<Routine Name=" MyToBeProtectedRoutine" Type="RLL" SourceKey="MyKey" SourceProtectionType="Full Protection"/>
All three examples protect the routine using the source key. The source is not viewable when the routine’s source key is not present.
Protect a routine and make its source viewable to the end user. This example protects the routine using the EncodedSourceKey and sets the SourceProtectionType to viewable.
<Routine Name=" MyToBeProtectedRoutine" Type="RLL" EncodedSourceKey=" CYARQ8c7nw4+PE9J6+goLDeCWB34Fz5K0s9Fc3Mz4JnIkmATTletANAADExXoQ5+" SourceProtectionType="Viewable"/>
</Routines>
Once these examples are imported, the MyToBeProtectedRoutine routine is protected.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.