(PureBasic) Extract a File from a .p7m (PKCS7 Signed-Data)
PureBasic 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.
IncludeFile "CkCrypt2.pb"
Procedure ChilkatExample()
; 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.i = CkCrypt2::ckVerifyP7M(crypt,inFile,outputFile)
If success = 0
Debug CkCrypt2::ckLastErrorText(crypt)
CkCrypt2::ckDispose(crypt)
ProcedureReturn
EndIf
Debug "Success!"
CkCrypt2::ckDispose(crypt)
ProcedureReturn
EndProcedure
|