Skip to main content

Quickstart Tutorial

Step 1: Initialize The SDK

The SDK requires an API key to communicate with the Sasha backend. The API key is passed during the init call.

Before any SDK operations can be performed, you must initialize SashaSDK. It is recommended to create a single instance of SashaSDK and share it throughout your application.

import SashaSDK

private let sashaSDK: SashaSDK
let configuration = SashaSDK.Configuration(
apiKey: "your-production-api-key-here",
environment: .production
)
self.sashaSDK = try SashaSDK(configuration: configuration)

note

Initializing SashaSDK comes with no performance or memory penalty. The initializer doesn't allocate heavy resources, start background tasks, or perform any network calls.

Step 2: Embed a Signature

To embed a signature, use the embedSignature method. This operation embeds a verifiable signature into the image data.

// Perform signing (runs on background threads)
let result = try await sashaSDK.embedSignature(image)

// Access results
let protectedImage = result.processedImage // CIImage
let signatureId = result.signatureId.value // UInt64

print("Signature embedded with ID: \(signatureId)")

Step 3: Verify the Signature

To verify a signature, use the lookupSignature method. This operation checks for the presence of a valid signature.

do {
// Scan for existing signature (non-blocking)
let signature = try await sashaSDK.lookupSignature(in: protectedImage)
print("Found signature with ID: \(signature.value)")
// Should match the signatureId from Step 2!
} catch SashaSDK.ProcessError.decodingError {
// No protection detected
print("No signature found in image")
}

✅ Success!

Congratulations! You've successfully protected your first image with SASHA on-device. You should now have:

  • ✅ An initialized SDK instance
  • ✅ A signature_id that uniquely identifies this protection
  • ✅ A protected image that looks identical to the original but contains the embedded signature
  • ✅ Verified the signature can be detected

What you learned

  • How to initialize the SASHA SDK
  • How to embed a signature into an image
  • How to verify a signature exists in an image
  • All processing happens on-device without server calls

Next Steps

Now that you've protected your first image, explore these topics: