Beispiel #1
0
 /// <summary>秘密鍵・復号化</summary>
 private void button2_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSCSalt.Text))
     {
         // ソルト無し
         if (this.rbnSCString.Checked)
         {
             // String
             this.txtSCString.Text =
                 SymmetricCryptography.DecryptString(
                     this.txtSCCode.Text,
                     this.txtSCPassword.Text,
                     (EnumSymmetricAlgorithm)cbxSCPV.SelectedValue);
         }
         else
         {
             // Bytes
             this.txtSCString.Text =
                 CustomEncode.ByteToString(
                     SymmetricCryptography.DecryptBytes(
                         CustomEncode.FormHexString(this.txtSCCode.Text),
                         this.txtSCPassword.Text,
                         (EnumSymmetricAlgorithm)cbxSCPV.SelectedValue),
                     CustomEncode.UTF_8);
         }
     }
     else
     {
         // ソルト有り
         if (this.nudSCStretching.Value == 0)
         {
             // ストレッチング無し
             if (this.rbnSCString.Checked)
             {
                 // String
                 this.txtSCString.Text
                     = SymmetricCryptography.DecryptString(
                           this.txtSCCode.Text,
                           this.txtSCPassword.Text,
                           (EnumSymmetricAlgorithm)cbxSCPV.SelectedValue,
                           CustomEncode.StringToByte(txtSCSalt.Text, CustomEncode.UTF_8));
             }
             else
             {
                 // Bytes
                 this.txtSCString.Text =
                     CustomEncode.ByteToString(
                         SymmetricCryptography.DecryptBytes(
                             CustomEncode.FormHexString(this.txtSCCode.Text),
                             this.txtSCPassword.Text,
                             (EnumSymmetricAlgorithm)cbxSCPV.SelectedValue,
                             CustomEncode.StringToByte(txtSCSalt.Text, CustomEncode.UTF_8)),
                         CustomEncode.UTF_8);
             }
         }
         else
         {
             // ストレッチング有り
             if (this.rbnSCString.Checked)
             {
                 // String
                 this.txtSCString.Text
                     = SymmetricCryptography.DecryptString(
                           this.txtSCCode.Text,
                           this.txtSCPassword.Text,
                           (EnumSymmetricAlgorithm)cbxSCPV.SelectedValue,
                           CustomEncode.StringToByte(txtSCSalt.Text, CustomEncode.UTF_8),
                           (int)this.nudSCStretching.Value);
             }
             else
             {
                 // Bytes
                 this.txtSCString.Text =
                     CustomEncode.ByteToString(
                         SymmetricCryptography.DecryptBytes(
                             CustomEncode.FormHexString(this.txtSCCode.Text),
                             this.txtSCPassword.Text,
                             (EnumSymmetricAlgorithm)cbxSCPV.SelectedValue,
                             CustomEncode.StringToByte(txtSCSalt.Text, CustomEncode.UTF_8),
                             (int)this.nudSCStretching.Value),
                         CustomEncode.UTF_8);
             }
         }
     }
 }