-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Аккаунты, криптография, серелизация xml и магазин
- Loading branch information
Showing
31 changed files
with
501 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using ServerTCP.Сryptographies; | ||
|
||
namespace LauncherDM.Models | ||
{ | ||
[Serializable] | ||
public class Users | ||
{ | ||
public string Login { get; set; } | ||
|
||
public string Password { get; set; } | ||
|
||
public string ImagePath { get; set; } | ||
|
||
private string Key = "fdjiaobzfddarkmilk"; | ||
public Users() { } | ||
|
||
public Users(string login, string password, string imagePath) | ||
{ | ||
Login = login; | ||
Password = password; | ||
ImagePath = imagePath; | ||
} | ||
|
||
public void cryptPassword() | ||
{ | ||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(Password)); | ||
var convertHash = Convert.ToHexString(hash); | ||
using (var myAes = Aes.Create()) | ||
{ | ||
byte[] aesKey = SHA256Managed.Create().ComputeHash(Encoding.UTF8.GetBytes(Key)); | ||
byte[] aesIV = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(Key)); | ||
myAes.Key = aesKey; | ||
myAes.IV = aesIV; | ||
var tokenResult = Convert.ToBase64String(CryptoAes.EncryptStringToBytes_Aes(convertHash, myAes.Key, myAes.IV)); | ||
Password = tokenResult; | ||
} | ||
} | ||
} | ||
|
||
[Serializable] | ||
public class UsersList | ||
{ | ||
public List<Users> UserList { get; set; } = new List<Users>(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Collections.Generic; | ||
using LauncherDM.Models; | ||
|
||
namespace LauncherDM.Services.Interfaces | ||
{ | ||
internal interface IXmlService | ||
{ | ||
void SerializationUsersXml(UsersList userlist); | ||
|
||
UsersList DeserializeUsersXMl(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Xml.Serialization; | ||
using LauncherDM.Models; | ||
using LauncherDM.Services.Interfaces; | ||
|
||
namespace LauncherDM.Services | ||
{ | ||
internal class XmlService : IXmlService | ||
{ | ||
private const string FileName = "Users.xml"; | ||
|
||
public void SerializationUsersXml(UsersList userlist) | ||
{ | ||
var xml = new XmlSerializer(typeof(UsersList)); | ||
using (var fs = new FileStream(FileName, FileMode.OpenOrCreate)) | ||
{ | ||
xml.Serialize(fs, userlist); | ||
} | ||
} | ||
|
||
public UsersList DeserializeUsersXMl() | ||
{ | ||
var userslist = new UsersList(); | ||
var xml = new XmlSerializer(typeof(UsersList)); | ||
using (var fs = File.Open(FileName, FileMode.OpenOrCreate)) | ||
{ | ||
try | ||
{ | ||
userslist = (UsersList)xml.Deserialize(fs); | ||
} | ||
catch | ||
{ | ||
} | ||
} | ||
return userslist; | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
|
||
|
||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
||
<Style x:Key="CenterTabPanel" TargetType="TabPanel"> | ||
<Setter Property="HorizontalAlignment" Value="Center"/> | ||
</Style> | ||
|
||
</ResourceDictionary> |
Oops, something went wrong.