Exemple #1
0
        public static string Decrypt(string Data, string Password, string Salt)
        {
            var keybytes = Encoding.UTF8.GetBytes(Password);
            var iv       = Encoding.UTF8.GetBytes(Salt);

            var decrypt = CryptoJS.DecryptStringFromBytes(Convert.FromBase64String(Data), keybytes, iv);

            return(decrypt.CompressFromUriEncoded());
            //var keybytes = Encoding.UTF8.GetBytes(Password);
            //var iv = Encoding.UTF8.GetBytes(Salt);

            ////var compdata = Data //.CompressFromUriEncoded(); //CryptoJS.DecryptStringFromBytes(Convert.FromBase64String(Data), keybytes, iv);
            //var decrypt = CryptoJS.DecryptStringFromBytes(Convert.FromBase64String(Data), keybytes, iv);

            //return decrypt; //.CompressFromBase64() ;
        }
Exemple #2
0
        public static string Encrypt(string Data, string Password, string Salt)
        {
            var compData = Data.CompressUriEncoded();
            var keybytes = Encoding.UTF8.GetBytes(Password);
            var iv       = Encoding.UTF8.GetBytes(Salt);

            return(Convert.ToBase64String(CryptoJS.EncryptStringToBytes(compData, keybytes, iv)));

            //Data.CompressUriEncoded();

            //var keybytes = Encoding.UTF8.GetBytes(Password);
            //var iv = Encoding.UTF8.GetBytes(Salt);
            //var compData = Convert.ToBase64String(CryptoJS.EncryptStringToBytes(Data, keybytes, iv));

            //return compData; //.CompressUriEncoded();
        }