none
error code cs1061 RRS feed

  • General discussion

  • I try this code but error occurs in "GetByte" anyone pls check and correct the erro pls

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Net.Sockets;
    using System.Text;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        string hash = "1234567890";

        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEncrypt_Click(object sender, EventArgs e)
        {

            byte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(txtValue.Text);
            using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
            {
                byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
                using (TripleDESCryptoServiceProvider tripDes = new TripleDESCryptoServiceProvider() { key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 })
                {
                    ICryptoTransform tranform = tripDes.CreateEncryptor();
                    byte[] result = tranform.TransformFinalBlock(data, 0, data.Length);
                    txtEncrypt.Text = Convert.ToBase64String(result, 0, result.Length);
                }
            }
        }
        protected void btnDecrypt_Click(object sender, EventArgs e)
        {
            byte[] data = Convert.FromBase64String(txtEncrypt.Text);
            using (MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider())
            {
                byte[] keys = MD5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash));
                using (TripleDESCryptoServiceProvider tripDes = new TripleDESCryptoServiceProvider() { key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 })
                {
                    ICryptoTransform tranform = tripDes.CreateDecryptor;
                    byte[] result = tranform.TransformFinalBlock(data, 0, data.Length);
                    txtEncrypt.Text = UTF8Encoding.UTF8.Getstring(result);
                }
            }
        }
    }
    public class UTF8Encoding
    {
        public static object UTF8 { get; internal set; }
    }

    Saturday, January 27, 2018 10:02 AM

All replies

  • Instead of UTF8Encoding.UTF8, use just Encoding.UTF8.

    The former has a property UTB of type Object, while the second is of type Encoding and has a method "GetBytes".

    Saturday, January 27, 2018 10:49 AM
    Moderator