Skip to content

Post-Build: Registering App Hash

After building your signed app, you must register the app hash with the Alphyn server.

Terminal window
# Make the script executable
chmod +x post-action-android.sh
# Run without API key (just shows app hash)
./post-action-android.sh /path/to/your-game.apk
# Run with API key (registers to server)
./post-action-android.sh /path/to/your-game.apk YOUR_API_KEY

The Android app hash is the SHA-256 of the app’s signing certificate (lowercase hex). It is the same for every build signed with the same key, so it changes only when you re-sign with a different one.

=== Android App Integrity Info ===
Package: com.yourstudio.yourgame
VersionCode: 1
VersionName: 1.0.0
Signer DN: CN=Your Studio, O=Your Studio, C=TR
AppHash: 64f3f5b47a856403dc48bfbaac0fcdb89f414f63dafb9c18e8b6d87f2a43caec (signing-certificate SHA-256)
isDebug: false
JSON:
{
"platform": "android",
"packageName": "com.yourstudio.yourgame",
"version": "1.0.0",
"appHash": "64f3f5b47a856403dc48bfbaac0fcdb89f414f63dafb9c18e8b6d87f2a43caec",
"isDebug": false
}
=== Registering to Server ===
Registration successful!

A Unity iOS build produces an Xcode project, and that project registers each archive the way a native iOS app does: from an Archive post-action in its scheme. The script is Assets/post-action-ios.sh in the Unity plugin package, the same script a native iOS app uses.

  1. Open the generated Xcode project and choose Product > Scheme > Edit Scheme….
  2. Select Archive, then Post-actions. Click + and choose New Run Script Action.
  3. Set Shell to /bin/bash and Provide build settings from to the Unity-iPhone target. Without build settings ARCHIVE_PATH is unset and the script exits without registering.
  4. Paste the contents of Assets/post-action-ios.sh, then replace alphyn_xxx in AUTH_TOKEN="alphyn_xxx" with the API key of your iOS app registration.
  5. Choose Product > Archive.

Unity’s Replace build mode clears the whole build folder, so a post-action added by hand does not survive a Replace build. Check that it is still in the scheme before you archive.

Step-by-step guide with screenshots: Register via Xcode post-action.

The post-action writes post_action.log and integrity.txt into the .xcarchive. integrity.txt lists the registered fields and ends with the register request and the HTTP status it got back. Inside the app it adds an encrypted AlphynBinaryManifest.json and re-signs the bundle; it leaves the game’s own files, StreamingAssets included, as Unity built them. The fields the SDK checks on the device:

FieldValue
computeMainExecutableHashExcludingSignature (cmeh)SHA-256 over the main executable’s __TEXT,__text hash, the Alphyn framework’s __TEXT,__text hash, the bundle identifier and the version. The build number is not part of it.
currentCDHashHex (cdh)HMAC-SHA256 of the bundle identifier, base64
computeBundleFingerprintExcludingSignatures (cbf)SHA-256 of embedded.mobileprovision
development_teamthe TeamIdentifier the app’s code signature carries, which is the team App Attest attests
  • Run the Android script AFTER signing your APK (release builds)
  • You need to re-register whenever you update your signing certificate
  • Android: The script requires Android SDK (aapt2 and apksigner)
  • iOS: The post-action runs inside Xcode on macOS, at archive time