00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004
00005 #include "nixsys.h"
00006 #include "rsa.h"
00007
00008 using namespace n2nc;
00009
00010 int main(int argc, char *argv[]){
00011 void *buf = malloc(256);
00012 void *buf2 = malloc(256);
00013 char *str= "encripted datajhjhgkhgfjhtguyty" ;
00014 char *key= "0123456789012345" ;
00015
00016 int outw,n ;
00017
00018 security::Rsa rs, rs2 ;
00019
00020
00021
00022
00023 rs.loadPubFromFile ("keypub");
00024 rs2.loadPriFromFile ("keypri");
00025
00026 if (argc < 2){
00027 std::cerr << "encripting" << std::endl ;
00028 outw = 0 ;
00029 while(n = ::read(0,buf,64)){
00030 outw = rs.encrypt(buf, buf2,n);
00031 ::write(1,buf2,outw);
00032 std::cerr << "written" << outw << "bytes" << std::endl ;
00033 }
00034 }else{
00035 outw = 0 ;
00036 std::cerr << "decripting" << std::endl ;
00037 while(n = ::read(0,buf,128)){
00038 outw = rs2.decrypt(buf, buf2,n);
00039 ::write(1,buf2,outw);
00040 std::cerr << "written" << outw << "bytes" << std::endl ;
00041
00042 }
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 return EXIT_SUCCESS;
00056 }
00057