-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrypto.cpp
45 lines (34 loc) · 806 Bytes
/
Crypto.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Open source not for commercial deployment
*/
//---------------------------------------------------------------------------
#pragma hdrstop
#include "Crypto.h"
#include "SongDataUnit.h"
int prevChar;
String DecryptString(String s)
{
if (SongData::Password.Length()==0) return "protected.";
String retval = "";
for (int i=1; i<=s.Length();i++)
{
int t = s[i]&0xFF;
t-=(prevChar + rand())%224;
if (t<32) t+=224;
retval += (char) t;
prevChar = s[i]&0xFF;
}
return retval;
}
void initPseudoRandom()
{
int t = 0;
for (int i=1; i<=SongData::Password.Length(); i++)
{
t *=3;
t += SongData::Password.operator [](i);
}
srand(t);
};
//---------------------------------------------------------------------------
#pragma package(smart_init)