chengyou
March 31st, 2004, 03:28
Hi,
I am a newbie. I try to use Cryptlib low level interface to run a demo using DES algorithm.
When I use MS Visual c++ 6.0 under Windows 2000 Pro to build this test.c file. This error occur:
cryptlib.h : fatal error LNK1136: invalid or corrupt file
Does any expert give me hint, thank you very very much in advance.
This is the test.c source code
#define INC_CHILD
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <string.h>
#include "crypt\des.h"
#include "cryptlib.h"
int main()
{
#define CRYPTLEN 128
#define BUFFERLENGTH (CRYPTLEN+64)
char CryptBuffer[BUFFERLENGTH];
int status;
int mode;
int ok1;
int i=0;
CRYPT_CONTEXT cryptContext;
// input crypt context buffer
printf("\nBitte eine Zeichenfolge eingeben:\nbis zu 32 Zeichen (256 Bit)\n\n>"
;
ok1=1;
while (((mode=getch()) != 13) && ok1==1)
{
putch(mode);
if (i < CRYPTLEN-1){
CryptBuffer[i++] = mode;
}
else{
printf("\nBuffer filled!"
;
ok1 = 0;
}
}
//last element to 0 for String with ending 0
CryptBuffer[i++] = 0;
printf("\n%s\n",CryptBuffer);
printf("\nEs werden %i Bytes verschluesselt\n", strlen(CryptBuffer));
/* Cryptlib Initialisierung */
status = cryptInit();
if( cryptStatusError( status ) )
{
printf( "cryptInit() failed with error code %d.\n", status );
return( -1 );
}
/* Load the key, encrypt the buffer, and destroy the encryption context */
cryptCreateContext( &cryptContext, CRYPT_UNUSED, CRYPT_ALGO_DES );
cryptGenerateKey( cryptContext );
printf( "\ntext: %s; textlen: %d", CryptBuffer, strlen(CryptBuffer));
/* Write the encrypted data to the screen */
printf( "\nContents of buffer after encryption: \n\n%.32s\n", CryptBuffer );
/* Load the key, decrypt the buffer, and destroy the encryption context */
cryptDecrypt( cryptContext, CryptBuffer, BUFFERLENGTH );
/* Write the decrypted data to the screen */
printf( "\nContents of buffer after decryption: \n\n%.32s\n\n", CryptBuffer );
printf( "\ntext: %s; textlen: %d", CryptBuffer, strlen(CryptBuffer));
cryptDestroyContext( cryptContext );
cryptEnd(); /* Cryptlib schliessen */
return 0;
}
I am a newbie. I try to use Cryptlib low level interface to run a demo using DES algorithm.
When I use MS Visual c++ 6.0 under Windows 2000 Pro to build this test.c file. This error occur:
cryptlib.h : fatal error LNK1136: invalid or corrupt file
Does any expert give me hint, thank you very very much in advance.
This is the test.c source code
#define INC_CHILD
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <string.h>
#include "crypt\des.h"
#include "cryptlib.h"
int main()
{
#define CRYPTLEN 128
#define BUFFERLENGTH (CRYPTLEN+64)
char CryptBuffer[BUFFERLENGTH];
int status;
int mode;
int ok1;
int i=0;
CRYPT_CONTEXT cryptContext;
// input crypt context buffer
printf("\nBitte eine Zeichenfolge eingeben:\nbis zu 32 Zeichen (256 Bit)\n\n>"

ok1=1;
while (((mode=getch()) != 13) && ok1==1)
{
putch(mode);
if (i < CRYPTLEN-1){
CryptBuffer[i++] = mode;
}
else{
printf("\nBuffer filled!"

ok1 = 0;
}
}
//last element to 0 for String with ending 0
CryptBuffer[i++] = 0;
printf("\n%s\n",CryptBuffer);
printf("\nEs werden %i Bytes verschluesselt\n", strlen(CryptBuffer));
/* Cryptlib Initialisierung */
status = cryptInit();
if( cryptStatusError( status ) )
{
printf( "cryptInit() failed with error code %d.\n", status );
return( -1 );
}
/* Load the key, encrypt the buffer, and destroy the encryption context */
cryptCreateContext( &cryptContext, CRYPT_UNUSED, CRYPT_ALGO_DES );
cryptGenerateKey( cryptContext );
printf( "\ntext: %s; textlen: %d", CryptBuffer, strlen(CryptBuffer));
/* Write the encrypted data to the screen */
printf( "\nContents of buffer after encryption: \n\n%.32s\n", CryptBuffer );
/* Load the key, decrypt the buffer, and destroy the encryption context */
cryptDecrypt( cryptContext, CryptBuffer, BUFFERLENGTH );
/* Write the decrypted data to the screen */
printf( "\nContents of buffer after decryption: \n\n%.32s\n\n", CryptBuffer );
printf( "\ntext: %s; textlen: %d", CryptBuffer, strlen(CryptBuffer));
cryptDestroyContext( cryptContext );
cryptEnd(); /* Cryptlib schliessen */
return 0;
}