CryptoSys PKI Pro Manual

CMS_MakeComprData

Creates a new CMS compressed-data file (.p7z) from an existing input file.

VBA/VB6 Syntax

Public Declare Function CMS_MakeComprData Lib "diCrPKI.dll" (ByVal strFileOut As String, ByVal strFileIn As String, ByVal nOptions As Long) As Long

nRet = CMS_MakeComprData(strFileOut, strFileIn, nOptions) As Long

C/C++ Syntax

long __stdcall CMS_MakeComprData(const char *szFileOut, const char *szFileIn, long nOptions);

Parameters

szFileOut
[in] name of output file to be created.
szFileIn
[in] name of file containing input data.
nOptions
[in] option flags: not used in this release. Specify zero.

Returns (VBA/C)

If successful, the return value is zero; otherwise it returns a negative error code.

.NET Equivalent

Cms.MakeComprData Method

C++ (STL) Equivalent

static int dipki::Cms::MakeComprData (const std::string &outputFile, const std::string &inputFile)

Python Equivalent

static Cms.make_comprdata(outputfile, inputfile)

Remarks

This creates a CMS compressed-data file (conventionally saved with a .p7z extension) using the zlibCompress algorithm. It only works in file-to-file mode. Any existing file with the same name as the parameter szFileOut will be overwritten without warning. Note that it may not produce an exact identical output to that of another program on the same input due to differences in ZLIB buffers and window sizes.

Example

Dim nRet As Long
Dim strBaseFile As String
Dim strCompFile As String
Dim strChkFile As String
Dim strFileType As String

strBaseFile = "sonnets.txt"
strCompFile = "sonnets.p7z"

' Create a CMS compressed-data file
nRet = CMS_MakeComprData(strCompFile, strBaseFile, 0)
Debug.Print "CMS_MakeComprData returns " & nRet & " (expecting 0)"
Debug.Print "FileLen('" & strBaseFile & "')=" & FileLen(strBaseFile)
Debug.Print "FileLen('" & strCompFile & "')=" & FileLen(strCompFile)

' Check ASN.1 file type
strFileType = String(PKI_ASN1_TYPE_MAXCHARS, " ")
nRet = ASN1_Type(strFileType, Len(strFileType), strCompFile, 0)
Debug.Print "File Type='" & Left(strFileType, nRet) & "'"

' Now check we can read it
strChkFile = "sonnets-uncompr.txt"
nRet = CMS_ReadComprData(strChkFile, strCompFile, 0)
Debug.Print "CMS_ReadComprData returns " & nRet & " (expecting +ve)"

' And check with no-inflate option
strChkFile = "sonnets-noinflate.txt"
nRet = CMS_ReadComprData(strChkFile, strCompFile, PKI_CMS_NO_INFLATE)
Debug.Print "CMS_ReadComprData(PKI_CMS_NO_INFLATE) returns " & nRet & " (expecting +ve)"
CMS_MakeComprData returns 0 (expecting 0)
FileLen('sonnets.txt')=106081
FileLen('sonnets.p7z')=40862
File Type='PKCS7/CMS COMPRESSED DATA                                       '
CMS_ReadComprData returns 106081 (expecting +ve)
CMS_ReadComprData(PKI_CMS_NO_INFLATE) returns 40770 (expecting +ve)

See Also

CMS_ReadComprData

[Contents] [Index]

[PREV: CMS_GetSigDataDigest...]   [Contents]   [Index]   
   [NEXT: CMS_MakeDetachedSig...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.