Home > Software engineering >  How to save data into suffix. Sam. SPC format file
How to save data into suffix. Sam. SPC format file

Time:10-02

In MFC, spectral instrument how can scan the original data stored as suffix. Sam. Spectra of SPC format file? How to open the suffix is called Sam. SPC file?

CodePudding user response:

Made a mistake, the suffix is. SPC! No. Sam. SPC

CodePudding user response:

Read and write files, change the filename suffix to SPC! Is ok

CodePudding user response:

In a normal file reading and writing, file extension is to see the operating system, open notepad, open the way can open to see

CodePudding user response:


refer to the second floor shiyanzi response:
, speaking, reading and writing files, change the filename suffix to. SPC! Can ah


reference lx624909677 reply: 3/f
in a normal file reading and writing, file extension is to see the operating system, open notepad, open the way can open to see


I checked the online, like SPC format is to use an encrypted PKCS # 7 digital signature of a format, using ordinary software cannot open, direct reading and writing the basic SPC format is garbled, I want to know if Microsoft have ready-made API or COM components can be used directly

CodePudding user response:

reference 4 floor WFTTTT response:
Quote: refer to the second floor shiyanzi response:

Read and write files, change the filename suffix to SPC! Can ah


reference lx624909677 reply: 3/f
in a normal file reading and writing, file extension is to see the operating system, open notepad, open the way can open to see


I checked the online, like SPC format is to use an encrypted PKCS # 7 digital signature of a format, using ordinary software cannot open, direct reading and writing the basic SPC format is garbled, I want to know if Microsoft have ready-made API or COM components can be used directly

Is I want to say is, the file format itself is a programmer to customize, as for the encryption process, is also a programmer to through encryption algorithm to control, on the common software can't open, that is because see is the ciphertext, need to decrypt the data in order to see the content, such as each character ward a, so you need to reach a decryption

CodePudding user response:

Fyi:
 # pragma comment (lib, "crypt32. Lib") 
# pragma comment (lib, "advapi32. Lib")
# define _WIN32_WINNT 0 x0400
#include
#include
#include
# define KEYLENGTH 0 x00800000
Void HandleError (char * s);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//These additional # define statements are required.
# define ENCRYPT_ALGORITHM CALG_RC4
# define ENCRYPT_BLOCK_SIZE 8
//Declare the function EncryptFile. The function definition
//follows the main.
BOOL EncryptFile (
PCHAR szSource,
PCHAR szDestination,
PCHAR szPassword);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//the Begin main.
Void main (void) {
CHAR szSource [100].
CHAR szDestination [100].
CHAR szPassword [100].
Printf (" Encrypt a file. \ n \ n ");
Printf (" Enter the name of the file to be encrypted: ");
The scanf (" % s ", szSource);
Printf (" Enter the name of the output file: ");
The scanf (" % s ", szDestination);
Printf (" Enter the password: ");
The scanf (" % s ", szPassword);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Call EncryptFile to do the actual encryption.
If (EncryptFile (szSource szDestination, szPassword)) {
Printf (" Encryption of the file % s was a success. \ n ", szSource);
Printf (" The encrypted data is in The file % s \ n ", szDestination);
} else {
HandleError (" Error encrypting file!" );
}
}//End of the main
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Code for the function EncryptFile called by the main.
The static BOOL EncryptFile (
PCHAR szSource,
PCHAR szDestination,
PCHAR szPassword)
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//the Parameters passed are:
//szSource, the name of the input, a plaintext file.
//szDestination, the name of the output, the an encrypted file to be
//created.
//szPassword, the password.
{
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Declare and initialize local variables.
The FILE * hSource;
The FILE * hDestination;
HCRYPTPROV HCRYPTPROV;
HCRYPTKEY hkeys;
HCRYPTHASH hHash;
PBYTE pbBuffer;
DWORD dwBlockLen;
DWORD dwBufferLen;
DWORD dwCount;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Open source file.
If (hSource=fopen (szSource, "rb")) {
Printf (" The source plaintext file, % s, is open. \ n ", szSource);
} else {
HandleError (" Error opening source plaintext file!" );
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Open the destination file.
If (hDestination=fopen (szDestination, "wb")) {
Printf (" Destination is open the file % s. \ n ", szDestination);
} else {
HandleError (" Error opening destination ciphertext file!" );
}
//the following for a CSP handle
If (CryptAcquireContext (
& HCryptProv,
NULL,//NULL said use the default key container, the default key container name
//for the user login name
NULL,
PROV_RSA_FULL,
{0))
Printf (" A cryptographic provider has had acquired. \ n ");
} else {
If (CryptAcquireContext (
& HCryptProv,
NULL,
NULL,
PROV_RSA_FULL,
CRYPT_NEWKEYSET))//create a key container
{
//create a key container is successful, and get the CSP handle
Printf (" A new key container has had been created. \ n ");
} else {
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related