Sample code for 30+ languages & platforms
Android™

Extract a File from a .p7m (PKCS7 Signed-Data)

See more Encryption Examples

_LANGUAGE_ example to extract the original file from a .p7m (Signed-Data PKCS7 Format) The .p7m contains the signed contents of the original file. It can be verified and restored by calling VerifyP7M.

Chilkat Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    boolean success = false;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkCrypt2 crypt = new CkCrypt2();

    // What is a .p7m file?

    String outputFile = "/Users/chilkat/testData/pdf/sample.pdf";
    String inFile = "/Users/chilkat/testData/p7m/sample.pdf.p7m";

    // Verify and restore the original file:
    success = crypt.VerifyP7M(inFile,outputFile);
    if (success == false) {
        Log.i(TAG, crypt.lastErrorText());
        return;
        }

    Log.i(TAG, "Success!");

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}