{ Analytica Model Example_of_Encrypt_and_Decrypt, encoding="UTF-8" } SoftwareVersion 7.2.1 { System Variables with non-default values: } SampleSize := 1000 TypeChecking := 1 Checking := 1 SaveOptions := 2 SaveValues := 0 {!-50299|DiagramColor Model: 0x00ffffff} {!-50299|DiagramColor Module: 0x00ffffff} {!-50299|DiagramColor LinkModule: 0x00ffffff} {!-50299|DiagramColor Library: 0x00ffffff} {!-50299|DiagramColor LinkLibrary: 0x00ffffff} {!-50299|DiagramColor Form: 0x00ffffff} NodeInfo FormNode: 1,0,0,,0,0,,,,0,,,0 {!-50299|NodeColor Text: 0x00f3f3f3} Model Example_of_Encrypt_and_Decrypt Title: Example of Encrypt and Decrypt Description: This illustrates a simple usage of Encrypt and Decrypt. Note that we have imported from the Crypto namespace. Author: Lonnie Chrisman, Ph.D.~ Lumina Decision Systems Date: Tue, Sep 22, 2026 9:44 AM DiagState: 2,0,1,1447,558,17,10 WindState: 2,98,82,720,350 FontStyle: Arial,15 FileInfo: 0,Model Example_of_Encrypt_and_Decrypt,2,2,0,0,W:\Testmodels\Example of Encrypt and Decrypt.ana {!60500|NamespaceImports: Crypto} {!70104|Att_GUID: d8dd5193-e6f1-400c-a4c7-7bac92071a36} Index I Title: I Definition: 1..100 NodeLocation: 160,96,1 NodeSize: 64,24 Variable bytes Title: bytes Description: A randomly generated array of integer byte values (0–255), one for each element of index I; used as the plaintext binary payload. Definition: Random(Uniform(0,255,integer:true,over:I)) NodeLocation: 320,96,1 NodeSize: 64,24 ValueState: 2,466,211,416,303,,MIDM Variable blob Title: blob Description: The binary payload created by packing the byte array into an in-memory binary value. Definition: WriteBinaryFile("<>",bytes,I,bytesPer:1,typeFlags:1) NodeLocation: 488,96,1 NodeSize: 64,24 ValueState: 2,148,154,416,303,,MIDM Variable key Title: key Description: A newly generated encryption key, used to encrypt and decrypt the example data. Definition: EncryptionKey() NodeLocation: 320,184,1 NodeSize: 64,24 ValueState: 2,260,266,416,303,,MIDM Variable Encrypted_blob Title: Encrypted blob Description: The binary blob sealed with the key using authenticated encryption, encoded as base64 text for convenient display or storage. Definition: Encrypt(blob,key,format:'base64') NodeLocation: 488,184,1 NodeSize: 64,24 ValueState: 2,292,298,986,251,,MIDM Variable Decrypted Title: Decrypted Description: The original binary blob recovered by decrypting Encrypted blob with the same key. Definition: Decrypt(Encrypted_blob, key) NodeLocation: 488,256,1 NodeSize: 64,24 ValueState: 2,324,330,416,303,,MIDM Variable Exploded_bytes Title: Exploded bytes Description: The decrypted binary blob unpacked back into its individual byte values along index I. Definition: GetFromBinaryData(Decrypted, bytesPer:1, typeFlags:0, resultIndex:I) NodeLocation: 664,256,1 NodeSize: 64,24 ValueState: 2,356,362,416,303,,MIDM Variable same_blob_ Title: same blob? Description: True when the decrypted value exactly matches the original binary blob, confirming successful round-trip encryption and decryption. Definition: blob=Decrypted NodeLocation: 672,184,1 NodeSize: 64,24 ValueState: 2,340,346,416,303,,MIDM Objective Correctly_recovered_ Title: Correctly recovered? Description: A sanity check -- did we recover the original data? Definition: Min(Exploded_bytes=bytes,I) NodeLocation: 664,344,1 NodeSize: 64,24 WindState: 2,608,416,720,350 ValueState: 2,372,378,416,303,,MIDM Variable Some_text Title: Some text Description: Example plaintext used to demonstrate encrypting and recovering ordinary text. Definition: "Now is the time for all good men to come to the aid of their country" NodeLocation: 328,432,1 NodeSize: 64,24 Variable Encrypted_text Title: Encrypted text Description: The example text sealed with the key using authenticated encryption in its native encrypted-value format. Definition: Encrypt(Some_text, key) NodeLocation: 496,432,1 NodeSize: 64,24 ValueState: 2,132,138,416,303,,MIDM Variable Recovered_text Title: Recovered text Description: The original example text recovered by decrypting Encrypted text with the same key. Definition: Decrypt(Encrypted_text,key) NodeLocation: 672,432,1 NodeSize: 64,24 ValueState: 2,148,154,944,167,,MIDM Variable Encrypted_text2 Title: Encrypted text2 Description: The example text sealed with the key and encoded as base64 text, suitable for text-only storage or transfer. Definition: Encrypt(Some_text, key, format:'base64') NodeLocation: 496,496,1 NodeSize: 64,24 ValueState: 2,100,106,416,303,,MIDM Variable Recovered_text1 Title: Recovered text Description: The original example text recovered by decrypting the base64-encoded encrypted text with the same key. Definition: Decrypt(Encrypted_text2, key, format:'base64') NodeLocation: 672,496,1 NodeSize: 64,24 ValueState: 2,116,122,416,303,,MIDM Close Example_of_Encrypt_and_Decrypt