Sample code for 30+ languages & platforms
PureBasic

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 PureBasic Downloads

PureBasic
IncludeFile "CkCrypt2.pb"

Procedure ChilkatExample()

    success.i = 0

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

    crypt.i = CkCrypt2::ckCreate()
    If crypt.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; What is a .p7m file?

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

    ; Verify and restore the original file:
    success = CkCrypt2::ckVerifyP7M(crypt,inFile,outputFile)
    If success = 0
        Debug CkCrypt2::ckLastErrorText(crypt)
        CkCrypt2::ckDispose(crypt)
        ProcedureReturn
    EndIf

    Debug "Success!"


    CkCrypt2::ckDispose(crypt)


    ProcedureReturn
EndProcedure