protected void Decode_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorTips.Text = emptyString;
                ErrorText.Text = emptyString;

                string encryptedText = EncryptedText.Text;
                string key           = KeyString.Text;

                EncoderV1.AssembleKeywords(key);

                string temp = EncoderV1.DecodeEncyptedTextToHexArray(encryptedText);

                if (key == null || key == "")
                {
                    ErrorText.Text = "请输入神秘代码哦。";
                }
                else if (temp == null && encryptedText != null)
                {
                    ErrorText.Text =
                        "对不起!您输入的神秘代码或待解码密文有问题,我解不出来…";
                }

                RawText.Text = temp;
            }
            catch (Exception ex)
            {
                ErrorTips.Text = errorCHN;
                ErrorText.Text = ex.Message;
            }
        }
        protected void Encode_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorTips.Text = emptyString;
                ErrorText.Text = emptyString;

                string rawText = RawText.Text;
                string key     = KeyString.Text;

                byte[] temp = EncoderV1.GetRawCodeFromText(rawText);
                EncoderV1.AssembleKeywords(key);
                string tempText = EncryptedText.Text = EncoderV1.ReplaceHexWithKeyText(temp);

                if (key == null || key == "")
                {
                    ErrorText.Text = "请输入神秘代码哦。";
                }
                else if (tempText == null)
                {
                    ErrorText.Text =
                        "对不起!您输入的神秘代码有问题,无法正常打码…注意不要使用重复字词哦!" +
                        "当神秘代码过短时,请慎用英文标点符号!更多请看“使用细节”页,或向开发者咨询。";
                }
            }
            catch (Exception ex)
            {
                ErrorTips.Text = errorCHN;
                ErrorText.Text = ex.Message;
            }
        }
Ejemplo n.º 3
0
        private void Encode_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorTips.Text = emptyString;
                ErrorText.Text = emptyString;

                string rawText = RawText.Text;
                string key     = KeyString.Text;

                byte[] temp = EncoderV1.GetRawCodeFromText(rawText);
                EncoderV1.AssembleKeywords(key);
                string tempText = EncryptedText.Text = EncoderV1.ReplaceHexWithKeyText(temp);

                if (key == null || key == "")
                {
                    ErrorText.Text = language == "CHN" ? "请输入神秘代码哦。" : "Please type in your key";
                }
                else if (tempText == null)
                {
                    ErrorText.Text = language == "CHN" ?
                                     "对不起!您输入的神秘代码或原文有问题,我无法正常打码…注意不要使用重复字词作为密码哦!" +
                                     "另外,当您使用的神秘代码过短时,请慎用英文标点符号!" :
                                     "Sorry, the key or the raw text you typed in does not work. Note that you should not use repeated words/letter sequence.";
                }
            }
            catch (Exception ex)
            {
                ErrorTips.Text = errorLangNow;
                ErrorText.Text = ex.Message;
            }
        }
Ejemplo n.º 4
0
        private void Decode_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorTips.Text = emptyString;
                ErrorText.Text = emptyString;

                string encryptedText = EncryptedText.Text;
                string key           = KeyString.Text;

                EncoderV1.AssembleKeywords(key);

                string temp = EncoderV1.DecodeEncyptedTextToHexArray(encryptedText);

                if (key == null || key == "")
                {
                    ErrorText.Text = language == "CHN" ? "请输入神秘代码哦。" : "Please type in your key";
                }
                else if (temp == null && encryptedText != null)
                {
                    ErrorText.Text = language == "CHN" ?
                                     "对不起!您输入的神秘代码或待解码密文有问题,我解不出来…" :
                                     "Sorry, the key or encrypted text you typed in does not work.";
                }

                RawText.Text = temp;
            }
            catch (Exception ex)
            {
                ErrorTips.Text = errorLangNow;
                ErrorText.Text = ex.Message;
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Enter the text:");
                string read = Console.ReadLine();
                if (read == "q")
                {
                    break;
                }

                Console.WriteLine("Enter the key string:");
                string key = Console.ReadLine();

                // Try encode
                byte[] temp = EncoderV1.GetRawCodeFromText(read);
                EncoderV1.AssembleKeywords(key);
                string enc = EncoderV1.ReplaceHexWithKeyText(temp);

                // Try decode


                Console.WriteLine();
            }
        }