namespace OubHackMS.Crypto
{
    using System;
    using System.Security.Cryptography;
    using System.Text;

    internal class RSA
    {
        private static RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(0x800);

        public static byte[] decrypt(string sXML, byte[] bData)
        {
            rsa.FromXmlString(sXML);
            return rsa.Decrypt(bData, true);
        }

        public static string decrypt(string sXML, string sData)
        {
            rsa.FromXmlString(sXML);
            return Encoding.UTF8.GetString(rsa.Decrypt(Encoding.UTF8.GetBytes(sData), true));
        }

        public static byte[] encrpyt(string sXML, byte[] bData)
        {
            rsa.FromXmlString(sXML);
            return rsa.Encrypt(bData, true);
        }

        public static string encrpyt(string sXML, string sData)
        {
            rsa.FromXmlString(sXML);
            return Encoding.UTF8.GetString(rsa.Encrypt(Encoding.UTF8.GetBytes(sData), true));
        }
    }
}

