개정판 4b97b147
add local license check for sppid
Change-Id: If25facd4d3520ce0bb105a868a3cd93457406c61
DTI_PID/SPPIDConverter/License.cs | ||
---|---|---|
148 | 148 |
{ |
149 | 149 |
bool result = false; |
150 | 150 | |
151 |
return true; |
|
151 |
// return true;
|
|
152 | 152 | |
153 | 153 |
try |
154 | 154 |
{ |
... | ... | |
156 | 156 |
if (!string.IsNullOrEmpty(key)) |
157 | 157 |
{ |
158 | 158 |
key = Crypt.decrypt(key, "dof1073#"); |
159 | ||
160 |
if (CheckLocalKey(key)) |
|
161 |
{ |
|
162 |
Settings.Default.LicenseKey = Crypt.encrypt(key, "dof1073#"); |
|
163 |
Settings.Default.Save(); |
|
164 | ||
165 |
return true; |
|
166 |
} |
|
159 | 167 |
} |
160 | 168 |
else |
161 | 169 |
{ |
... | ... | |
168 | 176 |
if (dlg.ShowDialog() == DialogResult.OK) |
169 | 177 |
{ |
170 | 178 |
key = dlg.key; |
179 | ||
180 |
if (CheckLocalKey(key)) |
|
181 |
{ |
|
182 |
Settings.Default.LicenseKey = Crypt.encrypt(key, "dof1073#"); |
|
183 |
Settings.Default.Save(); |
|
184 | ||
185 |
return true; |
|
186 |
} |
|
171 | 187 |
} |
172 | 188 | |
173 | 189 |
if (CheckLicense(key)) |
... | ... | |
196 | 212 |
return result; |
197 | 213 |
} |
198 | 214 | |
215 |
public static bool CheckLocalKey(string key) |
|
216 |
{ |
|
217 |
//return false; // for erase key |
|
218 |
try |
|
219 |
{ |
|
220 |
string _key = "Image Drawing to Intelligent Drawing"; |
|
221 | ||
222 |
string incoming = key.Replace('_', '/').Replace('-', '+'); |
|
223 |
switch (key.Length % 4) |
|
224 |
{ |
|
225 |
case 2: incoming += "=="; break; |
|
226 |
case 3: incoming += "="; break; |
|
227 |
} |
|
228 |
byte[] bytes = Convert.FromBase64String(incoming); |
|
229 |
string originalText = Encoding.ASCII.GetString(bytes); |
|
230 | ||
231 |
string decodeText = ""; |
|
232 |
//for (int i = 0; i < originalText.Length; i++) |
|
233 |
//{ |
|
234 |
// var key_c = _key[i % _key.Length]; |
|
235 |
// var dec_c = (char)((256 + originalText[i] - (key_c)) % 256); |
|
236 |
// decodeText += dec_c; |
|
237 |
//} |
|
238 |
for (int i = 0; i < bytes.Length; i++) |
|
239 |
{ |
|
240 |
var key_c = _key[i % _key.Length]; |
|
241 |
var dec_c = (char)((256 + bytes[i] - (key_c)) % 256); |
|
242 |
decodeText += dec_c; |
|
243 |
} |
|
244 | ||
245 |
if (SystemInformation.ComputerName == decodeText) |
|
246 |
{ |
|
247 |
return true; |
|
248 |
} |
|
249 |
} |
|
250 |
catch (Exception ex) |
|
251 |
{ |
|
252 |
// local key가 아님 |
|
253 |
} |
|
254 | ||
255 |
return false; |
|
256 |
} |
|
257 | ||
199 | 258 |
public static bool CheckLicense(string key) |
200 | 259 |
{ |
201 |
// return false; // for erase key
|
|
260 |
//return false; // for erase key |
|
202 | 261 |
try |
203 | 262 |
{ |
204 | 263 |
const string secret = "795hi#(7qq5&p#f3ysa#n-449h8g_n95olca)b%t23s7!w%v0m"; |
내보내기 Unified diff