hedayati.mo at gmail.com
Wed Dec 22 16:21:18 UTC 2010
On Wed, Dec 22, 2010 at 7:33 PM, Robert Bonomi <bonomi at mail.r-bonomi.com> wrote:
>> From owner-freebsd-questions at freebsd.org Wed Dec 22 08:22:15 2010
>> From: Mohammad Hedayati <hedayati.mo at gmail.com>
>> Date: Wed, 22 Dec 2010 17:50:19 +0330
>> To: freebsd-questions at freebsd.org
>> 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:
main(int argc, char *argv)
strncpy(key, "somekey", 8);
strncpy(buf, "sometxt", 8);
DES_ecb_encrypt(&buf, &buf, &schedule, 0);
DES_ecb_encrypt(&buf, &buf, &schedule, 1);
printf("Text Is: %s\n", buf);
More information about the freebsd-questions