-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
777 lines (673 loc) · 28.3 KB
/
Main.cs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
/*
TShock, a server mod for Terraria
Copyright (C) 2011-2012 The TShock Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.Cryptography;
using Mono.Data.Sqlite;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
namespace TShockDBEditor
{
public partial class TShockDBEditor : Form
{
public OpenFileDialog dialog = new OpenFileDialog();
public List<Group> groups = new List<Group>();
public static List<string> CommandList = new List<string>();
public IDbConnection DB;
public string dbtype = "";
public TShockDBEditor()
{
InitializeComponent();
Itemlist.AddItems();
dialog.FileOk += new CancelEventHandler(dialog_FileOk);
dialog.Filter = "SQLite Database (*.sqlite)|*.sqlite";
}
public void LoadDB()
{
itemListBanned.Items.Clear();
lst_groupList.Items.Clear();
lst_AvailableCmds.Items.Clear();
lst_bannedCmds.Items.Clear();
itemListAvailable.Items.Clear();
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Itembans";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
itemListBanned.Items.Add(reader.Get<string>("ItemName"));
}
}
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM GroupList";
lst_groupList.Items.Add("superadmin");
lst_usergrplist.Items.Add("superadmin");
lst_newusergrplist.Items.Add("superadmin");
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
lst_groupList.Items.Add(reader.Get<string>("GroupName"));
lst_inheritgrps.Items.Add(reader.Get<string>("GroupName"));
lst_usergrplist.Items.Add(reader.Get<string>("GroupName"));
lst_newusergrplist.Items.Add(reader.Get<string>("GroupName"));
}
}
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
foreach (string command in reader.Get<string>("Commands").Split(','))
{
if (!lst_groupList.Items.Contains(command))
if (!CommandList.Contains(command))
CommandList.Add(command);
}
}
}
TShockCommandsList.AddRemainingTShockCommands();
}
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Users";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
if (reader.Get<string>("UserName") != "")
lst_userlist.Items.Add(reader.Get<string>("UserName"));
else
lst_userlist.Items.Add(reader.Get<string>("IP"));
}
}
}
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Bans";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
lst_bans.Items.Add(reader.Get<string>("Name"));
}
}
}
for (int i = 0; i < Itemlist.ItemList.Count; i++)
{
if (!itemListBanned.Items.Contains(Itemlist.ItemList[i]))
itemListAvailable.Items.Add(Itemlist.ItemList[i]);
}
}
public void LoadSqliteDatabase(string path)
{
string sql = dialog.FileName;
DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
DB.Open();
dbtype = "sqlite";
LoadDB();
}
public void LoadMySqlDatabase(string hostname = "localhost", string port = "3306", string database = "", string dbusername = "", string dbpassword = "")
{
DB = new MySqlConnection();
DB.ConnectionString =
"Server='" + hostname +
"';Port='" + port +
"';Database='" + database +
"';Uid='" + dbusername +
"';Pwd='" + dbpassword + "';";
DB.Open();
dbtype = "mysql";
LoadDB();
}
#region BannedItemsTab
public void btn_moveAllRightItems_Click(object sender, EventArgs e)
{
foreach (object item in itemListAvailable.Items)
{
itemListBanned.Items.Add(item);
using (var com = DB.CreateCommand())
{
com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);";
com.AddParameter("@itemname", item.ToString());
com.ExecuteNonQuery();
com.Parameters.Clear();
}
}
itemListAvailable.Items.Clear();
}
private void btn_moveAllLeftItems_Click(object sender, EventArgs e)
{
foreach (object item in itemListBanned.Items)
{
itemListAvailable.Items.Add(item);
using (var com = DB.CreateCommand())
{
com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;";
com.AddParameter("@itemname", item.ToString());
com.ExecuteNonQuery();
com.Parameters.Clear();
}
}
itemListBanned.Items.Clear();
}
private void btn_moveRightItems_Click(object sender, EventArgs e)
{
if (itemListAvailable.SelectedItem != null)
{
itemListBanned.Items.Add(itemListAvailable.SelectedItem);
using (var com = DB.CreateCommand())
{
com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);";
com.AddParameter("@itemname", itemListAvailable.SelectedItem.ToString());
com.ExecuteNonQuery();
}
itemListAvailable.Items.Remove(itemListAvailable.SelectedItem);
}
}
private void btn_moveLeftItems_Click(object sender, EventArgs e)
{
if (itemListBanned.SelectedItem != null)
{
itemListAvailable.Items.Add(itemListBanned.SelectedItem);
using (var com = DB.CreateCommand())
{
com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;";
com.AddParameter("@itemname", itemListBanned.SelectedItem.ToString());
com.ExecuteNonQuery();
}
itemListBanned.Items.Remove(itemListBanned.SelectedItem);
}
}
#endregion
#region GroupTab
private void lst_groupList_SelectedIndexChanged(object sender, EventArgs e)
{
if ((string)lst_groupList.SelectedItem != "superadmin")
UpdateGroupIndex(lst_groupList.SelectedIndex);
else
lst_groupList.SelectedIndex = -1;
}
private void UpdateGroupIndex(int index)
{
try
{
using (var com = DB.CreateCommand())
{
lst_AvailableCmds.Items.Clear();
lst_bannedCmds.Items.Clear();
com.CommandText =
"SELECT * FROM GroupList WHERE GroupName=@groupname";
com.AddParameter("@groupname", lst_groupList.Items[index].ToString());
lbl_grpchild.Text = "";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
foreach (string command in reader.Get<string>("Commands").Split(','))
{
if (lst_groupList.Items.Contains(command) || command == "")
lbl_grpchild.Text = command;
else
lst_AvailableCmds.Items.Add(command);
}
}
}
if (lbl_grpchild.Text == "")
lbl_grpchild.Text = "none";
for (int i = 0; i < CommandList.Count; i++)
{
if (!lst_AvailableCmds.Items.Contains(CommandList[i]))
lst_bannedCmds.Items.Add(CommandList[i]);
}
}
}
catch { }
}
private void btn_moveAllRightCmd_Click(object sender, EventArgs e)
{
try
{
var sb = new StringBuilder();
foreach (object cmd in lst_bannedCmds.Items)
{
lst_AvailableCmds.Items.Add(cmd);
if (string.IsNullOrEmpty(sb.ToString()))
sb.Append(cmd.ToString());
else
sb.Append(",").Append(cmd.ToString());
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", sb.ToString());
com.ExecuteNonQuery();
}
lst_bannedCmds.Items.Clear();
}
catch { }
}
private void btn_moveRightCmd_Click(object sender, EventArgs e)
{
try
{
lst_AvailableCmds.Items.Add(lst_bannedCmds.Items[lst_bannedCmds.SelectedIndex]);
var sb = new StringBuilder();
foreach (object cmd in lst_AvailableCmds.Items)
{
if (string.IsNullOrEmpty(sb.ToString()))
sb.Append(cmd.ToString());
else
sb.Append(",").Append(cmd.ToString());
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", sb.ToString());
com.ExecuteNonQuery();
}
lst_bannedCmds.Items.Remove(lst_bannedCmds.Items[lst_bannedCmds.SelectedIndex]);
}
catch { }
}
private void btn_moveLeftCmd_Click(object sender, EventArgs e)
{
try
{
lst_bannedCmds.Items.Add(lst_AvailableCmds.Items[lst_AvailableCmds.SelectedIndex]);
lst_AvailableCmds.Items.Remove(lst_AvailableCmds.Items[lst_AvailableCmds.SelectedIndex]);
var sb = new StringBuilder();
foreach (object cmd in lst_AvailableCmds.Items)
{
if (string.IsNullOrEmpty(sb.ToString()))
sb.Append(cmd.ToString());
else
sb.Append(",").Append(cmd.ToString());
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", sb.ToString());
com.ExecuteNonQuery();
}
}
catch { }
}
private void btn_moveAllLeftCmd_Click(object sender, EventArgs e)
{
try
{
foreach (object cmd in lst_AvailableCmds.Items)
{
lst_bannedCmds.Items.Add(cmd);
}
using (var com = DB.CreateCommand())
{
com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;";
com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString());
com.AddParameter("@cmds", "");
com.ExecuteNonQuery();
}
lst_AvailableCmds.Items.Clear();
}
catch { }
}
private void btn_newgroup_Click(object sender, EventArgs e)
{
try
{
if (txt_grpname.Text != "")
{
using (var com = DB.CreateCommand())
{
if (dbtype == "sqlite")
com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands) VALUES (@groupname, @commands);";
else if (dbtype == "mysql")
com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands;";
com.AddParameter("@groupname", txt_grpname.Text);
if (lst_inheritgrps.SelectedIndex > -1)
com.AddParameter("@commands", lst_inheritgrps.Items[lst_inheritgrps.SelectedIndex]);
else
com.AddParameter("@commands", "");
using (var reader = com.ExecuteReader())
{
if (reader.RecordsAffected > 0)
{
lst_groupList.Items.Add(txt_grpname.Text);
lst_inheritgrps.Items.Add(txt_grpname.Text);
lst_usergrplist.Items.Add(txt_grpname.Text);
txt_grpname.Text = "";
}
}
com.Parameters.Clear();
}
}
}
catch { }
}
private void btn_deletegroup_Click(object sender, EventArgs e)
{
try
{
using (var com = DB.CreateCommand())
{
com.CommandText = "DELETE FROM Grouplist WHERE GroupName = @groupname";
com.AddParameter("@groupname", lst_groupList.Items[lst_groupList.SelectedIndex]);
com.ExecuteNonQuery();
lst_groupList.Items.Remove(lst_groupList.Items[lst_groupList.SelectedIndex]);
lst_inheritgrps.Items.Clear();
lst_usergrplist.Items.Clear();
com.CommandText =
"SELECT * FROM GroupList";
using (var reader = com.ExecuteReader())
{
while (reader.Read())
{
lst_inheritgrps.Items.Add(reader.Get<string>("GroupName"));
lst_usergrplist.Items.Add(reader.Get<string>("GroupName"));
}
}
}
}
catch { }
}
#endregion
#region FileOpenTabs
private void btn_OpenLocalDB_Click(object sender, EventArgs e)
{
dialog.ShowDialog();
}
void dialog_FileOk(object sender, CancelEventArgs e)
{
LoadSqliteDatabase(dialog.FileName);
tabControl.Visible = true;
}
private void btn_connect_Click(object sender, EventArgs e)
{
LoadMySqlDatabase(txt_hostname.Text, txt_port.Text, txt_dbname.Text, txt_dbusername.Text, txt_dbpassword.Text);
tabControl.Visible = true;
}
#endregion
#region BansTab
private void lst_bans_SelectedIndexChanged(object sender, EventArgs e)
{
using (var com = DB.CreateCommand())
{
if (lst_bans.SelectedIndex > -1)
{
com.CommandText =
"SELECT * FROM Bans WHERE Name=@name";
com.AddParameter("@name", lst_bans.Items[lst_bans.SelectedIndex]);
using (var reader = com.ExecuteReader())
{
if (reader.Read())
{
txt_banip.Text = reader.Get<string>("IP");
txt_banname.Text = reader.Get<string>("Name");
txt_banreason.Text = reader.Get<string>("Reason");
}
}
}
}
}
private void btn_bandelete_Click(object sender, EventArgs e)
{
using (var com = DB.CreateCommand())
{
com.CommandText =
"DELETE FROM Bans WHERE IP=@ip";
com.AddParameter("@ip", txt_banip.Text);
using (var reader = com.ExecuteReader())
{
if (reader.RecordsAffected > 0)
{
txt_banip.Text = "";
txt_banname.Text = "";
txt_banreason.Text = "";
lst_bans.Items.Remove(lst_bans.Items[lst_bans.SelectedIndex]);
}
}
}
}
private void btn_bannew_Click(object sender, EventArgs e)
{
using (var com = DB.CreateCommand())
{
if (dbtype == "sqlite")
com.CommandText = "INSERT INTO Bans (IP, Name, Reason) VALUES (@ip, @name, @reason);";
else if (dbtype == "mysql")
com.CommandText = "INSERT INTO Bans SET IP=@ip, Name=@name, Reason=@reason;";
if (txt_newbanip.Text != "" && txt_newbanname.Text != "")
{
com.AddParameter("@ip", txt_newbanip.Text);
com.AddParameter("@name", txt_newbanname.Text);
com.AddParameter("@reason", txt_newbanreason.Text);
com.ExecuteNonQuery();
lst_bans.Items.Add(txt_newbanname.Text);
txt_newbanip.Text = "";
txt_newbanname.Text = "";
txt_newbanreason.Text = "";
lbl_newbanstatus.Text = "Ban added successfully!";
}
else
lbl_newbanstatus.Text = "Required field('s) empty";
lst_bans.Items.Add(txt_newbanname.Text);
txt_newbanip.Text = "";
txt_newbanname.Text = "";
}
}
private void txt_banreason_TextChanged(object sender, EventArgs e)
{
if (txt_banip.Text != "")
{
using (var com = DB.CreateCommand())
{
com.CommandText =
"UPDATE Bans SET Reason=@reason WHERE IP=@ip";
com.AddParameter("@reason", txt_banreason.Text);
com.AddParameter("@ip", txt_banip.Text);
com.ExecuteNonQuery();
}
}
}
#endregion
#region UserTab
private void lst_userlist_SelectedIndexChanged(object sender, EventArgs e)
{
txt_username.Text = "None Selected";
txt_userip.Text = "None Selected";
lst_usergrplist.SelectedIndex = -1;
bool flag = false;
if (lst_userlist.SelectedIndex > -1)
{
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Users WHERE Username=@name";
com.AddParameter("@name", lst_userlist.Items[lst_userlist.SelectedIndex]);
using (var reader = com.ExecuteReader())
{
if (reader.Read())
{
txt_username.Text = reader.Get<string>("Username");
if (reader.Get<string>("IP") != "")
txt_userip.Text = reader.Get<string>("IP");
else
txt_userip.Text = "User does not have IP";
if (reader.Get<string>("Password") != "")
txt_userpass.Text = reader.Get<string>("Password");
else
txt_userpass.Text = "User does not have Pasword";
foreach (string name in lst_usergrplist.Items)
{
if (name == reader.Get<string>("Usergroup"))
{
lst_usergrplist.SelectedItem = name;
break;
}
}
}
else
flag = true;
}
}
if (flag)
{
using (var com = DB.CreateCommand())
{
com.CommandText =
"SELECT * FROM Users WHERE IP=@ip";
com.AddParameter("@ip", lst_userlist.Items[lst_userlist.SelectedIndex]);
using (var reader = com.ExecuteReader())
{
if (reader.Read())
{
if (reader.Get<string>("Password") != "")
txt_userpass.Text = reader.Get<string>("Password");
else
txt_userpass.Text = "User does not have Pasword";
txt_userip.Text = lst_userlist.Items[lst_userlist.SelectedIndex].ToString();
foreach (string name in lst_usergrplist.Items)
{
if (name == reader.Get<string>("Usergroup"))
{
lst_usergrplist.SelectedItem = name;
break;
}
}
}
}
}
}
}
}
private void lst_usergrplist_SelectedIndexChanged(object sender, EventArgs e)
{
if (lst_userlist.SelectedIndex > -1)
{
using (var com = DB.CreateCommand())
{
com.CommandText =
"UPDATE Users SET Usergroup=@group WHERE Username=@user OR IP=@ip";
com.AddParameter("@group", lst_usergrplist.SelectedItem);
com.AddParameter("@user", txt_username.Text);
com.AddParameter("@ip", txt_userip.Text);
com.ExecuteNonQuery();
}
}
}
private void btn_deluser_Click(object sender, EventArgs e)
{
if (lst_userlist.SelectedIndex > -1)
{
using (var com = DB.CreateCommand())
{
com.CommandText =
"DELETE FROM Users WHERE IP=@ip OR Username=@user";
com.AddParameter("@user", txt_username.Text);
com.AddParameter("@ip", txt_userip.Text);
com.ExecuteNonQuery();
lst_userlist.Items.Remove(lst_userlist.SelectedItem);
txt_userip.Text = "";
txt_username.Text = "";
txt_userpass.Text = "";
lst_usergrplist.SelectedIndex = -1;
lst_userlist.SelectedIndex = -1;
}
}
}
private void btn_adduser_Click(object sender, EventArgs e)
{
lbl_useraddstatus.Visible = true;
for (int i = 0; i == 0; i++)
{
if ((txt_newusername.Text == "" && txt_newuserpass.Text != ""))
{
lbl_useraddstatus.Text = "Username field cannot be empty";
break;
}
if ((txt_newusername.Text != "" && txt_newuserpass.Text == ""))
{
lbl_useraddstatus.Text = "Password field cannot be empty";
break;
}
if (txt_newuserip.Text == "" && (txt_newusername.Text == "" || txt_newuserpass.Text == ""))
{
lbl_useraddstatus.Text = "IP field cannot be empty";
break;
}
if (lst_newusergrplist.SelectedIndex == -1)
{
lbl_useraddstatus.Text = "Group must be selected";
break;
}
using (var com = DB.CreateCommand())
{
com.CommandText = "INSERT INTO Users (Username, Password, UserGroup, IP) VALUES (@name, @password, @group, @ip);";
com.AddParameter("@name", txt_newusername.Text);
com.AddParameter("@password", HashPassword(txt_newuserpass.Text));
com.AddParameter("@group", lst_newusergrplist.SelectedItem);
com.AddParameter("@ip", txt_newuserip.Text);
using (var reader = com.ExecuteReader())
{
if (reader.RecordsAffected > 0)
{
if (txt_newusername.Text != "")
lst_userlist.Items.Add(txt_newusername.Text);
else
lst_userlist.Items.Add(txt_newuserip.Text);
txt_newuserip.Text = "";
txt_newusername.Text = "";
txt_newuserpass.Text = "";
lst_newusergrplist.SelectedIndex = -1;
lbl_useraddstatus.Text = "User added successfully!";
}
else
lbl_useraddstatus.Text = "SQL error while adding user";
}
}
}
}
public static string HashPassword(string password)
{
using (var sha = new SHA512CryptoServiceProvider())
{
if (password == "")
{
return "nonexistent-password";
}
var bytes = sha.ComputeHash(Encoding.ASCII.GetBytes(password));
return bytes.Aggregate("", (s, b) => s + b.ToString("X2"));
}
}
#endregion
private void TShockDBEditor_Load(object sender, EventArgs e)
{
}
}
}