Ejemplo n.º 1
0
 /// <summary>共通鍵・復号化</summary>
 private void button5_Click(object sender, EventArgs e)
 {
     if (this.rbnASCString.Checked)
     {
         // String
         this.txtASCString.Text =
             ASymmetricCryptography.DecryptString(this.txtASCCode.Text, this.txtASCPrivate.Text);
     }
     else
     {
         // Bytes
         this.txtASCString.Text =
             CustomEncode.ByteToString(
                 ASymmetricCryptography.DecryptBytes(
                     CustomEncode.FormHexString(this.txtASCCode.Text), this.txtASCPrivate.Text),
                 CustomEncode.UTF_8);
     }
 }
Ejemplo n.º 2
0
        public void ToHexStringTest(byte[] bytes)
        {
            try
            {
                //convert to string using components of Touryo
                string strValue = CustomEncode.ToHexString(bytes);

                //convert to byte unsing components of Touryo
                byte[] bytesValue = CustomEncode.FormHexString(strValue);

                // Check whether it is converted to original byte.
                Assert.AreEqual(bytes, bytesValue);
            }
            catch (Exception ex)
            {
                // Print a stack trace when an exception occurs.
                Console.WriteLine(ex.StackTrace);
                throw;
            }
        }
Ejemplo n.º 3
0
        public void FormHexStringTest(string str)
        {
            try
            {
                //convert to byte using components of Touryo
                byte[] results = CustomEncode.FormHexString(str);

                //convert to string unsing components of Touryo
                string strValue = CustomEncode.ToHexString(results);

                // Check whether the two strings are equal.
                Assert.AreEqual(str, strValue);
            }
            catch (Exception ex)
            {
                // Print a stack trace when an exception occurs.
                Console.WriteLine(ex.StackTrace);
                throw;
            }
        }
Ejemplo n.º 4
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);
             }
         }
     }
 }