3 Please read the README file for condition of use, before
6 Maurice Gittens <mgittens@gits.nl> January 1997
14 #include <openssl/evp.h>
20 static const char *usage
= "Usage: example4 [-d]\n";
25 int main(int argc
, char *argv
[])
31 else if ((argc
== 2) && !strcmp(argv
[1],"-d"))
37 fprintf(stderr
,"%s", usage
);
51 EVP_EncodeInit(&ectx
);
55 int readlen
= read(STDIN
, buf
, sizeof(buf
));
68 EVP_EncodeUpdate(&ectx
, ebuf
, &ebuflen
, buf
, readlen
);
70 write(STDOUT
, ebuf
, ebuflen
);
73 EVP_EncodeFinal(&ectx
, ebuf
, &ebuflen
);
75 write(STDOUT
, ebuf
, ebuflen
);
85 EVP_DecodeInit(&ectx
);
89 int readlen
= read(STDIN
, buf
, sizeof(buf
));
103 rc
= EVP_DecodeUpdate(&ectx
, ebuf
, &ebuflen
, buf
, readlen
);
108 write(STDOUT
, ebuf
, ebuflen
);
112 fprintf(stderr
, "Error: decoding message\n");
116 write(STDOUT
, ebuf
, ebuflen
);
119 EVP_DecodeFinal(&ectx
, ebuf
, &ebuflen
);
121 write(STDOUT
, ebuf
, ebuflen
);