SDK API Reference
Embedding a Signature
To embed a signature, use the embedSignature
method. This operation embeds a verifiable signature into the image data.
- iOS
- Android
func embedSignature(in ciImage: CIImage) async throws(ProcessError) -> Signing.Output
Input Parameters:
ciImage
: ACIImage
representing the source image to be protected
Return Value:
Signing.Output
containing:signatureId
: Unique identifier (SignatureID
) for the embedded signatureprocessedImage
: The protected image as aCIImage
Example:
// Perform signing (runs on background threads)
let result = try await sashaSDK.embedSignature(image, options: options)
// Access results
let protectedImage = result.processedImage // CIImage
let signatureId = result.signatureId.value // UInt64
print("Signature embedded with ID: \(signatureId)")
suspend fun embedSignature(imageSource: ImageSource): Result<EmbeddedSignature>
Input Parameters:
imageSource
: AnImageSource
representing the source image to be protected
Return Value:
Result<EmbeddedSignature>
containing:data
: The processed image asPixelBufferData
signatureId
: Unique identifier (ULong
) for the embedded signature
Example:
suspend fun signImage(imageUri: Uri) {
val imageSource = ImageSource.Uri(context, imageUri)
sashaSDK.embedSignature(imageSource)
.onSuccess { response ->
val signedBitmap = response.data.toBitmap()
// Use the signed bitmap
}
.onFailure { error ->
// Handle signing error
}
}
Looking Up a Signature
To verify a signature, use the lookupSignature
method. This operation checks for the presence of a valid signature.
- iOS
- Android
func lookupSignature(in ciImage: CIImage) async throws(ProcessError) -> SignatureID
Input Parameters:
ciImage
: ACIImage
to scan for existing signatures
Return Value:
SignatureID
containing the unique identifier of the detected signature
Throws:
ProcessError.decodingError
if no signature is found or image cannot be processed
Example:
do {
// Scan for existing signature (non-blocking)
let signature = try await sashaSDK.lookupSignature(in: image)
print("Found signature with ID: \(signature.value)")
return signature.value
} catch SashaSDK.ProcessError.decodingError {
// No protection detected
print("No signature found in image")
return nil
}
suspend fun lookupSignature(imageSource: ImageSource): Result<LookupSignature>
Input Parameters:
imageSource
: AnImageSource
to scan for existing signatures
Return Value:
Result<LookupSignature>
containing:signatureId
: Unique identifier if signature found,null
otherwise
Example:
suspend fun lookupSignature(imageSource: ImageSource): Result<LookupSignature> {
val imageSource = ImageSource.Uri(context, imageUri)
sashaSDK.lookupSignature(imageSource)
.onSuccess { response ->
if (response.signatureId != null) {
// Signature found
} else {
// No signature found
}
}
.onFailure { error ->
// Handle lookup error
}
}
Environment Configuration
SashaSDK supports two environments:
- iOS
- Android
let prodConfig = SashaSDK.Configuration(
apiKey: "your-production-api-key"
)
val prodConfig = SashaSDK.Configuration(
apiKey = "your-production-api-key"
)
Set the requested environment to run the SDK in as part of the Configuration object submitted to the init
method.