1 /**
2  *  Yudit Unicode Editor Source File
3  *
4  *  GNU Copyright (C) 1997-2020  Gaspar Sinai <gaspar@yudit.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License, version 2,
8  *  dated June 1991. See file COPYYING for details.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef SSedy_h
21 #define SSedy_h
22 
23 #include <stoolkit/SString.h>
24 #include <stoolkit/SStringVector.h>
25 
26 // Encryption is loaded as an external dll because
27 // of export restrictions.
28 extern "C"
29 {
30     typedef struct _SSedyFunctions {
31         void* (*sedy_create) (char* password, char* cypher);
32         void (*sedy_destroy) (void* sedy);
33         char* (*sedy_get_result) (void* sedy);
34         unsigned long (*sedy_get_result_size) (void* sedy);
35         int (*sedy_encrypt)(void* sedy, char * buffer, unsigned long buffer_size);
36         int (*sedy_decrypt)(void* sedy, char * buffer, unsigned long buffer_size);
37         // Get last cypher.
38         char* (*sedy_get_cypher)(void* sedy);
39     } SSedyFunctions;
40 }
41 
42 class SSedy {
43 public:
44     SSedy ();
45     ~SSedy ();
46     SString encrypt (const SString& text, const SString& passWord);
47     SString decrypt (const SString& text, const SString& passWord);
48     static SString loadLibrary (const SStringVector& path);
49     static SString getLocation ();
50     SString getLastError();
51     SString getLastCypher();
52 private:
53     void prepareLastError();
54     SString lastError;
55 };
56 #endif /* SSedy_h */
57