Using crypto++ Topic is solved
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Using crypto++
Hey,
Has anybody here used crypto++ with wxwidgets? Basically, I'm looking for an (easier) way to encrypt a wxString that will be outputted to a file...
Thanks,
FlyingIsFun1217
Has anybody here used crypto++ with wxwidgets? Basically, I'm looking for an (easier) way to encrypt a wxString that will be outputted to a file...
Thanks,
FlyingIsFun1217
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
Re: Using crypto++
I usually use this. I hope to help you.FlyingIsFun1217 wrote:Hey,
Has anybody here used crypto++ with wxwidgets? Basically, I'm looking for an (easier) way to encrypt a wxString that will be outputted to a file...
Thanks,
FlyingIsFun1217
Code: Select all
const wxChar* Codes64 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
wxString EnCode64(wxString str)
{
int a=0,b=0,x;
const wxChar* Cstr = str.GetData();
wxString Result = wxEmptyString;
for (int i =0; i<str.Length(); i++)
{
wxString c = (wxString)Cstr[i];
if(c.IsAscii())
{
x = Cstr[i];
b = 256 * b + x;
a += 8;
while (a>=6)
{
a -= 6;
x = b / (1 << a);
b = b % (1 << a);
Result << Codes64[x+1];
}
}
else
Result << c;
}
if (a>0)
{
x = b << (6-a);
Result << Codes64[x+1];
}
return Result;
}
wxString DeCode64(wxString str)
{
int a=0,b=0,x;
const wxChar* Cstr = str.GetData();
wxString Result = wxEmptyString;
static wxString StringCodes64 = wxString::Format(Codes64);
for (int i=0; i<str.Length(); i++)
{
x = StringCodes64.Find(Cstr[i]) - 1;
if (x>=0)
{
b = b * 64 + x;
a+= 6;
if (a>=8)
{
a-= 8;
x = b >> a;
b = b % (1 << a);
x %= 256;
Result << (wxChar)x;
}
}
else
Result << (wxString)Cstr[i];
}
return Result;
}
- T U R K E Y ?
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
Re: Using crypto++
Do you use this to encrypt strings without using crypto++ at all? I don't see any refrence to it in the code...emarti wrote:I usually use this. I hope to help you.FlyingIsFun1217 wrote:Hey,
Has anybody here used crypto++ with wxwidgets? Basically, I'm looking for an (easier) way to encrypt a wxString that will be outputted to a file...
Thanks,
FlyingIsFun1217
Code: Select all
const wxChar* Codes64 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; wxString EnCode64(wxString str) { int a=0,b=0,x; const wxChar* Cstr = str.GetData(); wxString Result = wxEmptyString; for (int i =0; i<str.Length(); i++) { wxString c = (wxString)Cstr[i]; if(c.IsAscii()) { x = Cstr[i]; b = 256 * b + x; a += 8; while (a>=6) { a -= 6; x = b / (1 << a); b = b % (1 << a); Result << Codes64[x+1]; } } else Result << c; } if (a>0) { x = b << (6-a); Result << Codes64[x+1]; } return Result; } wxString DeCode64(wxString str) { int a=0,b=0,x; const wxChar* Cstr = str.GetData(); wxString Result = wxEmptyString; static wxString StringCodes64 = wxString::Format(Codes64); for (int i=0; i<str.Length(); i++) { x = StringCodes64.Find(Cstr[i]) - 1; if (x>=0) { b = b * 64 + x; a+= 6; if (a>=8) { a-= 8; x = b >> a; b = b % (1 << a); x %= 256; Result << (wxChar)x; } } else Result << (wxString)Cstr[i]; } return Result; }
FlyingIsFun1217
-
- Filthy Rich wx Solver
- Posts: 210
- Joined: Sat May 07, 2005 8:24 pm
- Location: Eskisehir, TURKEY
- Contact:
Sorry, I do not know it that library. In fact, My solution is very easy than crypto++. I downloaded it, I am trying... I'll be write to found alternative solution.
- T U R K E Y ?
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
- I love this country!
WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
...so you don't use crypto++? If so, I'll look at the code and see how I can impliment it into my code...emarti wrote:Sorry, I do not know it that library. In fact, My solution is very easy than crypto++. I downloaded it, I am trying... I'll be write to found alternative solution.
FlyingIsFun1217
------------------EDIT-----------------
After looking at the code, I would like to try it, but I'm not quite sure how to use it...
Would I save that code as a header file, or would I insert it it straight into my code?
Thanks!
FlyingIsFun1217
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm
-
- Super wx Problem Solver
- Posts: 497
- Joined: Mon Nov 06, 2006 9:58 pm