Unicode Intrinsic Functions - Encrypt Method

Encrypt the string using the TEA algorithm

Member of Unicode Intrinsic Functions (PRIM_LIBI.IUnicodeIntrinsics)

Parameters

NameTypeData TypeDescription
Result*Result (Optional)Unicode StringResulting encrypted string
Key*InputUnicode StringKey used to encrypt the value

Details

The Encrypt method uses a maximum 16 byte (128 bit) key to encrypt the supplied value.
 
This can be decrypted using the Decrypt intrinsic.

Example

In this example, the entered value is encrypted and then decrypted using the original key and and incorrect key.
 
The result of the wrong key being used is undecipherable.
Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#xDemoTheme)
   Define_Com Class(#xDemoAlpha256.Visual) Name(#Value) Displayposition(5) Left(16) Parent(#COM_OWNER) Tabposition(1) Top(88) Height(25) Width(769) Caption('Text to Encrypt') Labeltype(Caption)
   Define_Com Class(#xDemoAlpha256.Visual) Name(#Key) Displayposition(1) Left(16) Parent(#COM_OWNER) Tabposition(2) Top(120) Height(25) Width(769) Caption('Encryption Key') Labeltype(Caption)
   Define_Com Class(#xDemoAlpha256.Visual) Name(#EncryptedValue) Displayposition(4) Left(16) Parent(#COM_OWNER) Tabposition(5) Top(168) Height(25) Width(769) Caption('Encrypted Value') Labeltype(Caption) Readonly(True)
   Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Enter a value and key to see the encrypted value') Displayposition(6) Ellipses(Word) Height(66) Left(8) Parent(#COM_OWNER) Tabposition(6) Tabstop(False) Top(7) Verticalalignment(Center) Width(793) Themedrawstyle('DarkTitle+Heading1') Alignment(Center)
   Define_Com Class(#xDemoAlpha256.Visual) Name(#DecryptedValue) Displayposition(3) Left(16) Parent(#COM_OWNER) Tabposition(4) Top(200) Height(25) Width(769) Caption('Decrypted Value') Labeltype(Caption) Readonly(True)
   Define_Com Class(#xDemoAlpha256.Visual) Name(#FailedDecryption) Displayposition(2) Left(16) Parent(#COM_OWNER) Tabposition(3) Top(232) Height(25) Width(769) Caption('Failed Decryption') Labeltype(Caption) Readonly(True)
 
   Evtroutine Handling(#Value.Changed #Key.Changed)
 
      #EncryptedValue := #Value.Encrypt( #Key )
 
      #DecryptedValue := #EncryptedValue.Decrypt( #Key )
      #FailedDecryption := #EncryptedValue.Decrypt( "XXX" )
 
   Endroutine
 
End_Com

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2