<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# API Reference — Implementing Mobile App Hardening

## ProGuard / R8 (Android)
```groovy
// build.gradle
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
```

```
# proguard-rules.pro
-keep class com.app.models.** { *; }
-obfuscationDictionary dict.txt
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
```

## Android Keystore API
```kotlin
KeyGenerator.getInstance("AES", "AndroidKeyStore")
KeyGenParameterSpec.Builder(alias, PURPOSE_ENCRYPT or PURPOSE_DECRYPT)
    .setBlockModes(BLOCK_MODE_GCM)
    .setEncryptionPaddings(ENCRYPTION_PADDING_NONE)
    .setUserAuthenticationRequired(true)
    .build()
```

## EncryptedSharedPreferences
```kotlin
EncryptedSharedPreferences.create(
    context, "prefs", masterKey,
    PrefKeyEncryptionScheme.AES256_SIV,
    PrefValueEncryptionScheme.AES256_GCM
)
```

## iOS Keychain
```swift
let query: [String: Any] = [
    kSecClass: kSecClassGenericPassword,
    kSecAttrAccount: "key_name",
    kSecValueData: data,
    kSecAttrAccessible: kSecAttrAccessibleWhenUnlockedThisDeviceOnly
]
SecItemAdd(query as CFDictionary, nil)
```

## Network Security Config (Android)
```xml
<network-security-config>
  <domain-config>
    <domain includeSubdomains="true">api.example.com</domain>
    <pin-set expiration="2025-01-01">
      <pin digest="SHA-256">base64hash=</pin>
    </pin-set>
  </domain-config>
</network-security-config>
```

## SwiftShield (iOS obfuscation)
```bash
swiftshield obfuscate --project-file App.xcodeproj
```
