Hi everyone
I have a C# code but I am not familiar with this language
I want to convert this code to b4j code
Friends who know, please help
I have a C# code but I am not familiar with this language
I want to convert this code to b4j code
Friends who know, please help
C#:
private void GenerateToken()
{
Random random = new Random();
string text = random.NextDouble().ToString();
int[] array = new int[8] { 1382640238, 1684104556, 1701069673, 1885889906, 1299145829, 1298492783, 1920553844, 1919246701 };
uint[] array2 = new uint[4] { 825438784u, 1935959604u, 892749397u, 1663718965u };
List<byte> list = new List<byte>();
List<byte> list2 = new List<byte>();
for (int i = 0; i < array.Length; i++)
{
list.AddRange(BitConverter.GetBytes(array[i]).Reverse());
}
for (int j = 0; j < array2.Length; j++)
{
list2.AddRange(BitConverter.GetBytes(array2[j]).Reverse());
}
byte[] inArray = Encrypter(text, list.ToArray(), list2.ToArray());
string value = Convert.ToBase64String(inArray);
//["s"] = text;
//["c"] = value;
}
private byte[] Encrypter(string randomst, byte[] array1, byte[] array2)
{
if (randomst == null || randomst.Length <= 0)
{
throw new ArgumentNullException("plainText");
}
if (array1 == null || array1.Length == 0)
{
throw new ArgumentNullException("Key");
}
if (array2 == null || array2.Length == 0)
{
throw new ArgumentNullException("IV");
}
using Aes aes = Aes.Create();
aes.Key = array1;
aes.IV = array2;
ICryptoTransform transform = aes.CreateEncryptor(aes.Key, aes.IV);
using MemoryStream memoryStream = new MemoryStream();
using CryptoStream stream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
using (StreamWriter streamWriter = new StreamWriter(stream))
{
streamWriter.Write(randomst);
}
return memoryStream.ToArray();
}