mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-22 04:35:52 +12:00
Remove " " space from the names
This commit is contained in:
parent
bef3032886
commit
8e451633dc
59 changed files with 391 additions and 391 deletions
87
Horse Isle Server/HorseIsleServer/Security/Authentication.cs
Normal file
87
Horse Isle Server/HorseIsleServer/Security/Authentication.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Security
|
||||
{
|
||||
class Authentication
|
||||
{
|
||||
public static string DecryptLogin(string encpass)
|
||||
{
|
||||
string decrypt = "";
|
||||
string ROTPOOL = "bl7Jgk61IZdnY mfDN5zjM2XLqTCty4WSEoKR3BFVQsaUhHOAx0rPwp9uc8iGve";
|
||||
string POSPOOL = "DQc3uxiGsKZatMmOS5qYveN71zoPTk8yU0H2w9VjprBXWn l4FJd6IRbhgACfEL";
|
||||
string ROTPOOL2 = "evGi8cu9pwPr0xAOHhUasQVFB3RKoESW4ytCTqLX2Mjz5NDfm YndZI16kgJ7lb";
|
||||
|
||||
|
||||
int i = 0;
|
||||
int ii = 0;
|
||||
while (i < encpass.Length)
|
||||
{
|
||||
int ROT = ROTPOOL.IndexOf(encpass[i].ToString());
|
||||
int POS = POSPOOL.IndexOf(encpass[i + 1].ToString());
|
||||
POS -= (ROT + ii);
|
||||
if (POS < 0)
|
||||
{
|
||||
POS = (POS / -1) - 1;
|
||||
|
||||
while (POS >= ROTPOOL.Length)
|
||||
{
|
||||
POS -= ROTPOOL.Length;
|
||||
}
|
||||
|
||||
decrypt += ROTPOOL2[POS];
|
||||
}
|
||||
else
|
||||
{
|
||||
while (POS >= ROTPOOL.Length)
|
||||
{
|
||||
POS -= ROTPOOL.Length;
|
||||
}
|
||||
|
||||
decrypt += ROTPOOL[POS];
|
||||
}
|
||||
|
||||
i += 2;
|
||||
ii += 1;
|
||||
}
|
||||
return decrypt.Replace(" ", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static byte[] HashAndSalt(string plaintext, byte[] salt)
|
||||
{
|
||||
byte[] plaintextBytes = Encoding.UTF8.GetBytes(plaintext);
|
||||
|
||||
SHA512 sha512 = new SHA512Managed();
|
||||
byte[] hash = sha512.ComputeHash(plaintextBytes);
|
||||
|
||||
for (int i = 0; i < hash.Length; i++)
|
||||
{
|
||||
hash[i] ^= salt[i];
|
||||
}
|
||||
|
||||
|
||||
byte[] finalHash = sha512.ComputeHash(hash);
|
||||
|
||||
return finalHash;
|
||||
}
|
||||
|
||||
public static bool CheckPassword(string username, string password)
|
||||
{
|
||||
if(Database.CheckUserExist(username))
|
||||
{
|
||||
byte[] expectedPassword = Database.GetPasswordHash(username);
|
||||
byte[] salt = Database.GetPasswordSalt(username);
|
||||
byte[] hashedPassword = HashAndSalt(password, salt);
|
||||
|
||||
if (Enumerable.SequenceEqual(expectedPassword, hashedPassword))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using HISP.Properties;
|
||||
using System;
|
||||
using System.IO;
|
||||
using HISP.Server;
|
||||
namespace HISP.Security
|
||||
{
|
||||
class CrossDomainPolicy
|
||||
{
|
||||
public static byte[] GetPolicy()
|
||||
{
|
||||
if (!File.Exists(ConfigReader.CrossDomainPolicyFile)) {
|
||||
if (ConfigReader.Debug)
|
||||
Console.WriteLine("[DEBUG] Cross-Domain-Policy file not found, using default");
|
||||
File.WriteAllText(ConfigReader.CrossDomainPolicyFile, Resources.DefaultCrossDomain);
|
||||
}
|
||||
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
byte[] policyFileBytes = File.ReadAllBytes(ConfigReader.CrossDomainPolicyFile);
|
||||
ms.Write(policyFileBytes, 0x00, policyFileBytes.Length);
|
||||
ms.WriteByte(0x00);
|
||||
|
||||
ms.Seek(0x00, SeekOrigin.Begin);
|
||||
byte[] policyFileData = ms.ToArray();
|
||||
ms.Close();
|
||||
|
||||
return policyFileData;
|
||||
}
|
||||
}
|
||||
}
|
22
Horse Isle Server/HorseIsleServer/Security/RandomID.cs
Normal file
22
Horse Isle Server/HorseIsleServer/Security/RandomID.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
namespace HISP.Security
|
||||
{
|
||||
class RandomID
|
||||
{
|
||||
private static int prevId = 0;
|
||||
public static int NextRandomId(int randomId=-1)
|
||||
{
|
||||
int rndmId = 0;
|
||||
|
||||
if (randomId == -1)
|
||||
rndmId = prevId+1;
|
||||
else
|
||||
rndmId = randomId;
|
||||
|
||||
if (rndmId >= prevId)
|
||||
prevId = rndmId;
|
||||
|
||||
return rndmId;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue