Deploy a FireMonkey app and a small text file to an Android phone or an iPhone. On startup the app uses StreamSec to hash the installed file. The form displays StreamSec asset verified when the bytes match.
TLabel named ResultLabel and set its Align to Client.Source directory. For the Delphi 13 DCU trial, use Source\D13\android64\dcu for Android 64-bit and Source\D13\ios64\dcu for iOS Device 64-bit. See Add the library to a Delphi project.streamsec-mobile-check.txt beside the project. Save the single line StreamSec mobile in ASCII with one Windows line ending (CR LF). The expected digest includes that line ending.TaskMobile to the project. Declare MobileAssetStatus in its interface and put the following uses clause and implementation after implementation.uses
System.SysUtils, System.IOUtils,
stDERUtils, stSecUtils, stSHA256;
function MobileAssetStatus(const aDocumentsPath: string): string; const cExpected = '9c863d1968501817b1abc75ba20a532c11259139fca75bfa03ccf6f9432cef87'; var lFileName, lHash: string; begin lFileName := TPath.Combine(aDocumentsPath, 'streamsec-mobile-check.txt'); if not TFile.Exists(lFileName) then Exit('Asset missing'); lHash := OSToHex(DigestFile(haSHA256, lFileName), True); if SameText(lHash, cExpected) then Result := 'StreamSec asset verified' else Result := 'Asset contents differ'; end;
The stSHA256 unit registers the digest used by DigestFile. Add System.IOUtils and TaskMobile to the form unit's implementation uses clause. In the Object Inspector, create the form's OnCreate handler and give it the body shown below. The example's form class is TMobileForm. Keep the wizard's System.StartUpCopy unit in the project source so the data file is copied to the app's private storage on launch.
procedure TMobileForm.FormCreate(Sender: TObject); begin ResultLabel.Text := MobileAssetStatus(TPath.GetDocumentsPath); end;
streamsec-mobile-check.txt, set its Remote Path to assets\internal\ and keep the file enabled.TPath.GetDocumentsPath. Check that the label displays StreamSec asset verified.For device detection and SDK selection, see Running an Android application on a device.
StartUp\Documents\.StreamSec asset verified message on the iPhone.For signing and profile selection, see Provisioning an iOS application.
Asset missing means the app could not find the file at the expected path. Check the file name, remote path and enabled deployment entry for the platform and configuration you actually ran. Asset contents differ means a file was present and its digest differed. Check the exact text, line ending and absence of a byte-order mark. Startup copying preserves an existing file in the app's Documents directory. To check a corrected asset, deploy to a fresh installation of this sample on a test device. Deployment entries apply to the selected configuration. When switching to Release, check the file's entry for that configuration too. See Adding files in the Deployment Manager.
stSecUtils · stSHA256 · stDERUtils