B4J Question Help changing .Net to B4X

noxius3

Member
Hello. There is a program written in .Net. I'm rewriting it on B4X. Basic functions work, but stuck on the password encryption module.

Here's the encryption code itself::
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;

namespace AccountContracts
{
    public static class PasswordUtils
    {
        public static string Decrypt(string source, string date)
        {
            string str;
            byte[] numArray1;
            if (String.IsNullOrEmpty(source) || String.IsNullOrEmpty(date) || source.Length > 160)
            {
                return null;
            }
            try
            {
                string str1 = new String(date.Reverse<char>().ToArray<char>());
                using (MD5 mD5 = MD5.Create())
                {
                    numArray1 = mD5.ComputeHash(Encoding.UTF8.GetBytes(str1));
                }
                int num1 = 0;
                byte[] array = Convert.FromBase64String(source).Select<byte, byte>((byte p) => {
                    if (num1 > (int)numArray1.Length - 1)
                    {
                        num1 = 0;
                    }
                    byte[] numArray = numArray1;
                    int num = num1;
                    num1 = num + 1;
                    return (byte)(p ^ numArray[num]);
                }).ToArray<byte>();
                str = Encoding.UTF8.GetString(array);
            }
            catch
            {
                str = null;
            }
            return str;
        }
    }
}

Could you help with that?
 
Top