Date: Wed, 22 Dec 2010 19:50:36 +0330 From: Mohammad Hedayati <hedayati.mo@gmail.com> To: freebsd-questions@freebsd.org Subject: Re: DES Cipher Message-ID: <AANLkTikyfhXiu5pFkwBs5GLnvHoLgioVTkFWGT_nJwky@mail.gmail.com> In-Reply-To: <201012221603.oBMG3AnT016020@mail.r-bonomi.com> References: <201012221603.oBMG3AnT016020@mail.r-bonomi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 22, 2010 at 7:33 PM, Robert Bonomi <bonomi@mail.r-bonomi.com> w=
rote:
>
>> From owner-freebsd-questions@freebsd.org =C2=A0Wed Dec 22 08:22:15 2010
>> From: Mohammad Hedayati <hedayati.mo@gmail.com>
>> Date: Wed, 22 Dec 2010 17:50:19 +0330
>> To: freebsd-questions@freebsd.org
>> Subject: DES Cipher
>>
>> Can anyone please show me a sample code for ciphering using DES in FreeB=
SD?
>
> I hate to say it, but RTFM applies.
> 'apropos encryption' gives, among other things (and first), a cite to bde=
s(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);
=09
DES_set_key(&key, &schedule);
=09
DES_cblock buf;
strncpy(buf, "sometxt", 8);
=09
// Encrypting
DES_ecb_encrypt(&buf, &buf, &schedule, 0);=09
=09
// Decrypting
DES_ecb_encrypt(&buf, &buf, &schedule, 1);=09
printf("Text Is: %s\n", buf);
=09
return(0);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikyfhXiu5pFkwBs5GLnvHoLgioVTkFWGT_nJwky>
