当前位置: 首页>>代码示例>>C#>>正文


C# Encryption类代码示例

本文整理汇总了C#中Encryption的典型用法代码示例。如果您正苦于以下问题:C# Encryption类的具体用法?C# Encryption怎么用?C# Encryption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Encryption类属于命名空间,在下文中一共展示了Encryption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveRegister

        private bool SaveRegister(string RegisterKey)
        {
            try
            {
                
                Encryption enc = new Encryption();
                FileStream fs = new FileStream("reqlkd.dll", FileMode.Create);
                XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

                // Khởi động tài liệu.
                w.WriteStartDocument();
                w.WriteStartElement("QLCV");

                // Ghi một product.
                w.WriteStartElement("Register");
                w.WriteAttributeString("GuiNumber", enc.EncryptData(sGuiID));
                w.WriteAttributeString("Serialnumber", enc.EncryptData(sSerial));
                w.WriteAttributeString("KeyRegister", enc.EncryptData(RegisterKey, sSerial + sGuiID));
                w.WriteEndElement();

                // Kết thúc tài liệu.
                w.WriteEndElement();
                w.WriteEndDocument();
                w.Flush();
                w.Close();
                fs.Close();
                return true;
            }
            catch (Exception ex)
            {

                return false;
            }
        }
开发者ID:phinq19,项目名称:qlcongviec,代码行数:34,代码来源:frmRegister.cs

示例2: btnSubmit_Click

 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     int idCustomer = Convert.ToInt32(dtableCustomer.Rows[0]["ID"].ToString());
     string userName = dtableCustomer.Rows[0]["UseName"].ToString();
     string newPass = EnscryptionPassword();
     string name = tbxName.Text;
     bool gender = Getgender();
     string phone = tbxPhone.Text;
     string address = tbxAddress.Text;
     string email = tbxEmail.Text;
     string oldPass = new Encryption().Encrypt(FunctionLibrary.KEY_ENSCRYPTION, tbxOldPassword.Text);
     if (oldPass.Equals(dtableCustomer.Rows[0]["Password"].ToString()))
     {
         if (accountBAL.UpdateCustomer(userName, newPass, name, gender, phone, address, email, idCustomer))
         {
             lblMessErrorGetPass.Visible = true;
             lblMessErrorGetPass.Text = "Change Profile Success";
         }
     }
     else
     {
         lblMessErrorGetPass.Visible = true;
         lblMessErrorGetPass.Text = "Old Password Is Not Match";
     }
 }
开发者ID:tringuyenvn94,项目名称:web-ban-hang,代码行数:25,代码来源:User.aspx.cs

示例3: validateLicense

        public bool validateLicense(string licenseFile, string key1, string key2, string keys)
        {
            bool validLicense = false;
            try
            {
                StreamReader sr = new StreamReader(licenseFile);

                Networking net = new Networking();
                Encryption enc = new Encryption();

                string licenseInfo = sr.ReadToEnd();

                string licenseInfoDecrypted = enc.DecryptString(licenseInfo, key1, key2);
                sr.Close();

                string[] liInfo = licenseInfoDecrypted.Split(' ');

                if (liInfo[0] == net.GetMACAddress().ToString() && validateKey(liInfo[1], keys) == true)
                {

                   validLicense = true;
                }

            }
            catch (Exception)
            {
                ;
            }

            return validLicense;
        }
开发者ID:jansky,项目名称:NetLicensing,代码行数:31,代码来源:Validation.cs

示例4: btnTempPW_Click

 protected void btnTempPW_Click(object sender, EventArgs e)
 {
     string password = Membership.GeneratePassword(7, 3);
     txtUserPW.Text = password;
     Encryption enc = new Encryption();
     password = enc.AESEncrypt256(password);
 }
开发者ID:comsiro,项目名称:SimpleBoard,代码行数:7,代码来源:AddUser.aspx.cs

示例5: MakeItSo

    protected void MakeItSo(object sender, System.EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["BrowserDate"];
        if (cookie == null)
        {
            cookie = new HttpCookie("BrowserDate");
            cookie.Value = DateTime.Now.ToString();
            cookie.Expires = DateTime.Now.AddDays(22);
            Response.Cookies.Add(cookie);
        }
        try
        {
            Encryption encrypt = new Encryption();

            DateTime isn = DateTime.Now;

            if (!DateTime.TryParse(cookie.Value.ToString().Replace("%20", " ").Replace("%3A", ":"), out isn))
                isn = DateTime.Now;
            DateTime isNow = isn;
            Data dat = new Data(isn); if (Page.IsValid)
            {
                if (DBConnection(UserNameTextBox.Text.Trim(), encrypt.encrypt(PasswordTextBox.Text.Trim())))
                {
                    string groups = "";
                    SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ToString());
                    myConn.Open();
                    SqlCommand myCmd = new SqlCommand("SELECT U.Password, U.User_ID, UP.CatCountry, UP.CatState, UP.CatCity, U.UserName FROM Users U, UserPreferences UP WHERE U.User_ID=UP.UserID AND [email protected]", myConn);
                    myCmd.CommandType = CommandType.Text;
                    myCmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = UserNameTextBox.Text.Trim();
                    DataSet ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter(myCmd);
                    da.Fill(ds);
                    myConn.Close();
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        dat.WhatHappensOnUserLogin(ds);

                        string redirectTo = "my-account";
                        if (Session["RedirectTo"] != null)
                            redirectTo = Session["RedirectTo"].ToString();

                        Response.Redirect(redirectTo, false);
                    }
                    else
                    {

                        StatusLabel.Text = "Invalid Login, please try again!";
                    }
                }
                else
                {
                    StatusLabel.Text = "Invalid Login, please try again!";
                }
            }
        }
        catch (Exception ex)
        {
            StatusLabel.Text = ex.ToString();
        }
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:60,代码来源:UserLogin.aspx.cs

示例6: OpenMessage

    protected void OpenMessage(object sender, EventArgs e)
    {
        string id = "";
        string eType = "";
        if (Request.QueryString["ID"] != null)
        {
            id = Request.QueryString["ID"].ToString();
            eType = "V";
        }
        else if (Request.QueryString["AdID"] != null)
        {
            id = Request.QueryString["AdID"].ToString();
            eType = "A";
        }
        else if (Request.QueryString["EventID"] != null)
        {
            id = Request.QueryString["EventID"].ToString();
            eType = "E";
        }

        Encryption encrypt = new Encryption();
        MessageRadWindow.NavigateUrl = "MessageAlert.aspx?T=Flag&EType="+eType+"&message=" + encrypt.encrypt(message)+"&ID="+id;
        MessageRadWindow.Visible = true;

        MessageRadWindowManager.VisibleOnPageLoad = true;
    }
开发者ID:aleksczajka,项目名称:Hippo-Code---OLD,代码行数:26,代码来源:FlagItem.ascx.cs

示例7: SetUp

 public void SetUp()
 {
     e = new Encryption();
     encryption = MockRepository.GenerateMock<IEncryption>();
     log = MockRepository.GenerateMock<ILog>();
     encryption.Expect(x => x.Decrypt(e.Encrypt(ConnectionString))).Return(ConnectionString);
 }
开发者ID:perryofpeek,项目名称:SqlToGraphitePlugin-SqlServer,代码行数:7,代码来源:With_SqlServerClient.cs

示例8: GenerationKey

        public static string GenerationKey(string strSystemInfoKey)
        {
            try
            {
                string text1 = strSystemInfoKey.Split(new char[] { '-' })[0].ToUpper();
                string text2 = strSystemInfoKey.Split(new char[] { '-' })[1].ToUpper();
                string text3 = strSystemInfoKey.Split(new char[] { '-' })[2].ToUpper();
                string text4 = strSystemInfoKey.Split(new char[] { '-' })[3].ToUpper();
                string text5 = strSystemInfoKey.Split(new char[] { '-' })[4].ToUpper();

                //Mã hóa key
                Encryption enc = new Encryption(UserName, Password);
                text1 = SystemInfo.RemoveUseLess(enc.Encrypt(text1).ToUpper());
                text2 = SystemInfo.RemoveUseLess(enc.Encrypt(text2).ToUpper());
                text3 = SystemInfo.RemoveUseLess(enc.Encrypt(text3).ToUpper());
                text4 = SystemInfo.RemoveUseLess(enc.Encrypt(text4).ToUpper());
                text5 = SystemInfo.RemoveUseLess(enc.Encrypt(text5).ToUpper());

                return text1.Substring(0, 5) + "-" + text2.Substring(0, 5) + "-" + text3.Substring(0, 5) + "-" + text4.Substring(0, 5) + "-" + text5.Substring(0, 5);
            }
            catch(Exception ex)
            {
                return "";
            }
        }
开发者ID:romeobk,项目名称:HRMS_7Cua,代码行数:25,代码来源:License.cs

示例9: Connection

 public Connection(TcpClient tcpCon, Encryption server)
 {
     tcpClient = tcpCon;
     serverEncryption = server;
     thrSender = new Thread(AcceptClient);
     thrSender.Start();
 }
开发者ID:toniertl1988,项目名称:cuddychat,代码行数:7,代码来源:Connection.cs

示例10: XmlSettings

 /// <summary>
 /// Constructs an instance of the <c>XmlSettings</c> class.
 /// </summary>
 /// <param name="filename">Name of the settings file.</param>
 /// <param name="encryption"><c>Encryption</c> instance used for encrypted settings. May be <c>null</c>
 /// if no settings use the <c>EncryptedSetting</c> attribute.</param>
 public XmlSettings(string filename, Encryption encryption)
     : base(encryption)
 {
     if (String.IsNullOrWhiteSpace(filename))
         throw new ArgumentException("A valid path and file name is required.", nameof(filename));
     FileName = filename;
 }
开发者ID:SoftCircuits,项目名称:Toxic,代码行数:13,代码来源:XmlSettings.cs

示例11: generateJSON

        /// <summary
        /// GetData , then encrypt , then Compress file and copy to file system
        /// </summary>
        /// <param name="datasetIds"></param>
        /// <param name="filePath"></param>
        /// <param name="folderPath"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public DataResponseModel generateJSON(List<int> datasetIds , string filePath , string folderPath , string fileName)
        {
            DataResponseModel dataResponseModel = new DataResponseModel();

            DataSetRepo dataSetRepo = new DataSetRepo();
            JsonDatasetModel Jdsm = dataSetRepo.GetData(datasetIds, filePath);

            if (Jdsm == null)
            {
                dataResponseModel.IsValid = true;
                dataResponseModel.Error = "Dataset Not Exist";
                return dataResponseModel;
            }

            #region Encrypt
            Encryption ec = new Encryption();
            JsonDatasetModel encryptedData = ec.Secure(Jdsm);
            #endregion

            #region CompressFileAndCopyToFileSystem
            CompressFile cf = new CompressFile();
            cf.GetCompressed(Jdsm, filePath, folderPath, fileName);
            #endregion

            return dataResponseModel;
        }
开发者ID:mdhammad313,项目名称:PharmaGuideCloud,代码行数:34,代码来源:GenerateJSON.cs

示例12: btnEncrypt_Click

 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     _type = (Tritemius.OffsetType)cmbEncryptionType.SelectedItem;
     _encryption = new Tritemius(rtbInput.Text, tbKey.Text, _type);
     rtbOutput.Clear();
     rtbOutput.Text = _encryption.Encrypt();
 }
开发者ID:NotYours180,项目名称:Encryption,代码行数:7,代码来源:TritemiusForm.cs

示例13: LaunchAuth

 private void LaunchAuth(object sender, DoWorkEventArgs e)
 {
     if(Client.Properties.Settings.Default.FirstTimeLaunch == true) {
         Encryption encr = new Encryption();
         string encryptionKeys = encr.CreateKeyPair();
         char[] delimiterChars = { ':' };
         string[] encryptions = encryptionKeys.Split(delimiterChars);
         Properties.Settings.Default.PublicKey = encryptions[1];
         Properties.Settings.Default.PrivateKey = encryptions[0];
         MiscMethods misc = new MiscMethods();
         Properties.Settings.Default.ClientID = misc.GetMacAddress();
         Packet sendPacket = new Packet();
         string packet = sendPacket.encodePacket(Properties.Settings.Default.ClientID.ToString(), 0, -1, publicKey, false);
     }
     else
     {
         Packet sendPacket = new Packet();
         string response = "";
         if (response == "success")
          {
         status.Image = Client.Properties.Resources.online;
         connectionStatus.Text = "- Online";
         Online = true;
          }
          else
         {
         status.Image = Client.Properties.Resources.offline;
         connectionStatus.Text = "- Offline";
         Online = false;
         }
     }
 }
开发者ID:cosmicpeanut,项目名称:ChatApplication,代码行数:32,代码来源:LandingPage.cs

示例14: Main

        public static void Main(string[] args)
        {
            Encryption encryption = new Encryption();
            encryption.DoEncryption();

            Decryption decryption = new Decryption();
            decryption.DoDecryption();
        }
开发者ID:BigBearGCU,项目名称:FNDEV-Week10-Cryptography,代码行数:8,代码来源:Main.cs

示例15: TestEncryption_Click

        private void TestEncryption_Click(object sender, RoutedEventArgs e)
        {
            Encryption testEncryption = new Encryption();
            if (testEncryption.ShowDialog() == true)
            {

            }
        }
开发者ID:ReneNNielsen,项目名称:RNNEmailClient,代码行数:8,代码来源:MainWindow.xaml.cs


注:本文中的Encryption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。