1
/* First example: Encrypts stdin to stdout using TWOFISH with 128 bit key and CFB */
8
unsigned char ReadByte(char *s) {
10
str[0]=s[0];str[1]=s[1];str[2]=0;
11
return strtoul(str,NULL,16);
19
char s[]="101e966a2155120f79795782592f7aa75cb4";
26
td = mcrypt_module_open("twofish", NULL, "cfb", NULL);
27
if (td==MCRYPT_FAILED) {
32
if (ssize<2) return 1;
34
if (ssize<4+IVsize) return 1;
36
for (i=0,j=2;i<IVsize;i++,j+=2)
39
i=mcrypt_generic_init( td, tmpkey, tmpkeysize, IV);
46
for (i=0;i<ssize;i++,j+=2)
47
sout[i]=ReadByte(s+j);
50
mdecrypt_generic (td, sout, ssize);
53
mcrypt_generic_end(td);