On Wed, Dec 22, 2010 at 7:33 PM, Robert Bonomi <[email protected]> wrote:
>
>> From [email protected] Wed Dec 22 08:22:15 2010
>> From: Mohammad Hedayati <[email protected]>
>> Date: Wed, 22 Dec 2010 17:50:19 +0330
>> To: [email protected]
>> Subject: DES Cipher
>>
>> Can anyone please show me a sample code for ciphering using DES in FreeBSD?
>
> I hate to say it, but RTFM applies.
> 'apropos encryption' gives, among other things (and first), a cite to bdes(1).
>
> 'bdes' is a program that comes with the FreeBSD distribution.
> You have access to the source code of all of the distribution.
>
> 'Use the Souce, Luke" applies, and will bring the mountain to Mohammad. :)
>
>
>
Thanks Robert, I haven't seen a cite to bdes in the FM of des(3), but
the problem is solved using the source of bdes(1) [thanks to Antone].
The code would be as easy as:
#include <openssl/des.h>
int
main(int argc, char *argv[])
{
DES_key_schedule schedule;
DES_cblock key;
strncpy(key, "somekey", 8);
DES_set_key(&key, &schedule);
DES_cblock buf;
strncpy(buf, "sometxt", 8);
// Encrypting
DES_ecb_encrypt(&buf, &buf, &schedule, 0);
// Decrypting
DES_ecb_encrypt(&buf, &buf, &schedule, 1);
printf("Text Is: %s\n", buf);
return(0);
}
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[email protected]"