home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- //
- // SAMPLE.C - Example of Blowfish API call.
- //
- // Compile this, and link with ENCRYPT.LIB to use encryption functions in DLL
- // (or link with ENCRYPT.OBJ to build stand-alone .EXE).
- //
- // Matthew Spencer, 18/8/95
- // Updated 22/7/97
- //
- ///////////////////////////////////////////////////////////////////////////////
- #include <stdio.h> // for printf()
- #include <string.h> // for strlen()
- #include "encrypt.h"
-
- int main()
- {
- unsigned char text[] = "This is the sample text to encrypt";
- unsigned char key[] = "A sample key.";
- int len = strlen(text);
-
- // set version
- SetVersion(161); // new requirement with version 1.61
-
- // intialise
- Initialise(key, strlen(key));
-
- // display original text
- printf("\nThe original text (%d bytes) is: >>%s<<\n\n", len, text);
-
- // call encryption
- EncryptBlock(text, len);
- printf("After encryption, the text is: >>%s<<\n\n", text);
-
- // call decryption - should be the same as the original
- DecryptBlock(text, len);
- printf("After decryption, the text is: >>%s<<\n\n", text);
-
- return 0;
- }
-