#include <iostream>
#include <cstring>
#include "base64.h"
#define ENCODE "/Encode"
#define DECODE "/Decode"
#define FILE "-File"
#define STR "-String"
using namespace std;
void Usage();
int main(int argc, char* argv[])
{
if( (argc != 4) )
{
Usage();
return 1;
}
if( (strcmp(argv[1], ENCODE) == 0) )
{
if( (strcmp(argv[2], FILE) == 0) )
{
if(!base64_encode_file(argv[3]))
{
cout << " File could not be encrypted!" <<endl;
}
else
{
cout << " File could be encrypted!" <<endl;
}
}
if( (strcmp(argv[2], STR) == 0) )
{
cout << base64_encode((const unsigned char *)argv[3], strlen(argv[3])) <<endl;
}
}
if( (strcmp(argv[1], DECODE) == 0) )
{
if( (strcmp(argv[2], FILE) == 0) )
{
if(!base64_decode_file(argv[3]))
{
cout << " File could not be decrypted!" <<endl;
}
else
{
cout << " File could be decrypted!" <<endl;
}
}
if( (strcmp(argv[2], STR) == 0) )
{
cout << base64_decode((string)argv[3]) <<endl;
}
}
return 0;
}
void Usage()
{
cout << "Usage:" <<endl;
cout << " Extasis [/Encode] [/Decode] [[-File] Path] [[-String] Text]" <<endl;
}