Simple encryption functions in Linux!

Phil Mattison plug-devel@lists.PLUG.phoenix.az.us
Wed Nov 10 06:01:02 2004


The following link describes to some extent how to use these functions:

http://ou800doc.caldera.com/en/man/html.3X/crypt.3X.html

The general idea is to use a hash function to generate a 64-byte key
block from a text pass phrase, and use setkey() to register that key
for use by the encryption algorithm. You then encrypt your data in
blocks of 64 bytes each, getting an enctypted 64-byte block in
return for each input block. Any partial block must be padded to
64 bytes with zeros or random data (preferred). The same key is
used later to decrypt.

I have a simple C++ DES encryption library in source form that
is pretty easy to use and doesn't try to be everything to everyone
like so many open-source projects, if you're interested. I can send
it via email offline with a simple example if you like. It's a single
.cpp and .h file.

--Phil M.
>
> Is there any simple text encryption functions available to use in a C =
> program in Linux. I've found encrypt/decrypt functions that are part of =
> libcrypt library. I couldn't figure out how to use them .=20
>
> The manual page has=20
>
> #include <crypt.h>
>
> main() {
>   char key[64];      /* bit pattern for key */
>   char txt[64];      /* bit pattern for messages */
>   setkey(key);
>   encrypt(txt, 0);   /* encode */
>   encrypt(txt, 1);   /* decode */
> }
>
> this example and says that to do useful work the key[] and txt[] array =
> must be filled with a useful bit pattern.I have tried with normal =
> string, it doesn't do anything. Has anybody used these functions =
> before?? Any ideas how to use these functions??=20
>
> Or are there any other encryption/decryption functions that I can use in =
> my C program?? All I need to do is read some text from a file and =
> encrypt it and may or may not write it back.=20