Created
February 13, 2021 13:35
-
-
Save MrOplus/6c8157b53c75fe7a480e9ce70b66189a to your computer and use it in GitHub Desktop.
AryaNet
This file contains hidden or 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
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Runtime.CompilerServices; | |
using System.Security.Cryptography; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace AryaNet_Client | |
{ | |
internal static class Aryanet_crypto | |
{ | |
public static async Task CopyDecryptAsync(Stream source, Stream destination, string aeskey, string addy, CancellationToken cancellationToken = null, int bufferSize = 4104) | |
{ | |
byte[] numArray = new byte[bufferSize]; | |
while (true) | |
{ | |
int num = await source.ReadAsync(numArray, 0, (int)numArray.Length, cancellationToken); | |
int num1 = num; | |
if (num <= 0) | |
{ | |
break; | |
} | |
if (aeskey != null) | |
{ | |
string str = BitConverter.ToString(numArray); | |
for (int i = 29; i > 0; i--) | |
{ | |
str = str.Replace(aeskey[i], '~').Replace(aeskey[i - 1], aeskey[i]).Replace('~', aeskey[i - 1]); | |
} | |
string[] strArrays = str.Split(new char[] { '-' }); | |
byte[] numArray1 = new byte[(int)strArrays.Length]; | |
for (int j = 0; j < (int)strArrays.Length; j++) | |
{ | |
numArray1[j] = Convert.ToByte(strArrays[j], 16); | |
} | |
await destination.WriteAsync(numArray1, 0, num1, cancellationToken); | |
} | |
else | |
{ | |
string str1 = BitConverter.ToString(numArray).Replace('2', '~').Replace('1', '2').Replace('~', '1'); | |
string[] strArrays1 = str1.Split(new char[] { '-' }); | |
byte[] num2 = new byte[(int)strArrays1.Length]; | |
for (int k = 0; k < (int)strArrays1.Length; k++) | |
{ | |
num2[k] = Convert.ToByte(strArrays1[k], 16); | |
} | |
await destination.WriteAsync(num2, 0, num1, cancellationToken); | |
} | |
cancellationToken.ThrowIfCancellationRequested(); | |
} | |
numArray = null; | |
} | |
public static async Task CopyEncryptAsync(Stream source, Stream destination, string aeskey, string addy, CancellationToken cancellationToken = null, int bufferSize = 4096) | |
{ | |
byte[] numArray = new byte[bufferSize]; | |
while (true) | |
{ | |
int num = await source.ReadAsync(numArray, 0, (int)numArray.Length, cancellationToken); | |
int num1 = num; | |
if (num <= 0) | |
{ | |
break; | |
} | |
if (aeskey != null) | |
{ | |
string str = BitConverter.ToString(numArray); | |
for (int i = 0; i < 29; i++) | |
{ | |
str = str.Replace(aeskey[i], '~').Replace(aeskey[i + 1], aeskey[i]).Replace('~', aeskey[i + 1]); | |
} | |
string[] strArrays = str.Split(new char[] { '-' }); | |
byte[] numArray1 = new byte[(int)strArrays.Length]; | |
for (int j = 0; j < (int)strArrays.Length; j++) | |
{ | |
numArray1[j] = Convert.ToByte(strArrays[j], 16); | |
} | |
await destination.WriteAsync(numArray1, 0, num1, cancellationToken); | |
cancellationToken.ThrowIfCancellationRequested(); | |
} | |
else | |
{ | |
string str1 = BitConverter.ToString(numArray).Replace('1', '~').Replace('2', '1').Replace('~', '2'); | |
string[] strArrays1 = str1.Split(new char[] { '-' }); | |
byte[] num2 = new byte[(int)strArrays1.Length]; | |
for (int k = 0; k < (int)strArrays1.Length; k++) | |
{ | |
num2[k] = Convert.ToByte(strArrays1[k], 16); | |
} | |
await destination.WriteAsync(num2, 0, num1, cancellationToken); | |
} | |
} | |
numArray = null; | |
} | |
public static byte[] DecryptCTTPT(byte[] toEncryptArray, int bytesRead, string _securityKey) | |
{ | |
MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider(); | |
byte[] numArray = mD5CryptoServiceProvider.ComputeHash(Encoding.UTF8.GetBytes(_securityKey)); | |
mD5CryptoServiceProvider.Clear(); | |
return (new TripleDESCryptoServiceProvider() | |
{ | |
Key = numArray, | |
Mode = CipherMode.ECB, | |
Padding = PaddingMode.PKCS7 | |
}).CreateDecryptor().TransformFinalBlock(toEncryptArray, 0, bytesRead); | |
} | |
public static byte[] EncryptPTTCT(byte[] toEncryptedArray, int bytesRead, string _securityKey) | |
{ | |
MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider(); | |
byte[] numArray = mD5CryptoServiceProvider.ComputeHash(Encoding.UTF8.GetBytes(_securityKey)); | |
mD5CryptoServiceProvider.Clear(); | |
return (new TripleDESCryptoServiceProvider() | |
{ | |
Key = numArray, | |
Mode = CipherMode.ECB, | |
Padding = PaddingMode.PKCS7 | |
}).CreateEncryptor().TransformFinalBlock(toEncryptedArray, 0, bytesRead); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment