Skip to main content

Signing Data

This snippet demonstrates how to use the private key to sign some text.

Prerequisites

Steps

  1. Add a new Swift file to your project, and copy the following code snippet:
// Create the private and public keys.
KeychainHelper.create("sample")
{
    success, _  in

    print("Private and public keys created successfully: \(success).")
}

// Sign the data.
guard let value = KeychainHelper.sign("sample", value: "hello world") else
{
    print("Unable to sign data with private key.")
    return
}

print("Signed data: \(value)")

// Delete the private key.
KeychainHelper.delete("sample")
{
    result in
    
    print("Private key deleted successful: \(result).")
}

Next Steps

You have now successfully used the private key to sign some text in your iOS application, by using the IBMVerifyKit framework.

Play around with other samples which demonstrate further functionality of the framework in the Samples section, or have a look at more quick, easy-to-implement code snippets in the Snippets section.