public void EncodeText(string text)
 {
     if (!string.IsNullOrEmpty(text))
     {
         Text   = text;
         Binary = TranslatorHelper.TextToBinary(text);
         Hex    = TranslatorHelper.TextToHexidecimal(text);
         ASCII  = TranslatorHelper.TextToASCII(text);
         Base64 = TranslatorHelper.TextToBase64(text);
         MD5    = TranslatorHelper.TextToCrypto(text, CryptoType.MD5);
         SHA1   = TranslatorHelper.TextToCrypto(text, CryptoType.SHA1);
     }
 }
        public bool DecodeHex(string hex)
        {
            string hexText = Regex.Replace(hex, @"[^0-9a-fA-F]", "");

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i + 2 <= hexText.Length; i += 2)
            {
                char c = (char)TranslatorHelper.HexToByte(hexText.Substring(i, 2));
                sb.Append(c);
            }

            return(DecodeReturn(sb.ToString()));
        }
        public bool DecodeBinary(string binary)
        {
            string binaryText = Regex.Replace(binary, @"[^01]", "");

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i + 8 <= binaryText.Length; i += 8)
            {
                char c = (char)TranslatorHelper.BinaryToByte(binaryText.Substring(i, 8));
                sb.Append(c);
            }

            return(DecodeReturn(sb.ToString()));
        }
Пример #4
0
        public bool EncodeText(string text)
        {
            if (!string.IsNullOrEmpty(text))
            {
                Text        = text;
                Binary      = TranslatorHelper.TextToBinary(text);
                Hexadecimal = TranslatorHelper.TextToHexadecimal(text);
                ASCII       = TranslatorHelper.TextToASCII(text);
                Base64      = TranslatorHelper.TextToBase64(text);
                MD5         = TranslatorHelper.TextToHash(text, HashType.MD5, true);
                SHA1        = TranslatorHelper.TextToHash(text, HashType.SHA1, true);
                SHA256      = TranslatorHelper.TextToHash(text, HashType.SHA256, true);
                SHA384      = TranslatorHelper.TextToHash(text, HashType.SHA384, true);
                SHA512      = TranslatorHelper.TextToHash(text, HashType.SHA512, true);
                RIPEMD160   = TranslatorHelper.TextToHash(text, HashType.RIPEMD160, true);
                return(true);
            }

            return(false);
        }
Пример #5
0
        private void CheckThread(object sender, DoWorkEventArgs e)
        {
            using (FileStream stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (HashAlgorithm hash = GetHashAlgorithm(HashType))
                    using (CryptoStream cs = new CryptoStream(stream, hash, CryptoStreamMode.Read))
                    {
                        long      bytesRead, totalRead = 0;
                        byte[]    buffer = new byte[8192];
                        Stopwatch timer  = Stopwatch.StartNew();

                        while ((bytesRead = cs.Read(buffer, 0, buffer.Length)) > 0 && !bw.CancellationPending)
                        {
                            totalRead += bytesRead;

                            if (timer.ElapsedMilliseconds > 200)
                            {
                                float progress = (float)totalRead / stream.Length * 100;
                                bw.ReportProgress(0, progress);
                                timer.Reset();
                                timer.Start();
                            }
                        }

                        if (bw.CancellationPending)
                        {
                            bw.ReportProgress(0, 0f);
                            e.Cancel = true;
                        }
                        else
                        {
                            bw.ReportProgress(0, 100f);
                            string[] hex = TranslatorHelper.BytesToHexadecimal(hash.Hash);
                            e.Result = string.Concat(hex);
                        }
                    }
        }
Пример #6
0
        public bool DecodeBase64(string base64)
        {
            string result = TranslatorHelper.Base64ToText(base64);

            return(EncodeText(result));
        }
Пример #7
0
        public bool DecodeASCII(string ascii)
        {
            string result = TranslatorHelper.ASCIIToText(ascii);

            return(EncodeText(result));
        }
Пример #8
0
        public bool DecodeHex(string hex)
        {
            string result = TranslatorHelper.HexadecimalToText(hex);

            return(EncodeText(result));
        }
Пример #9
0
        public bool DecodeBinary(string binary)
        {
            string result = TranslatorHelper.BinaryToText(binary);

            return(EncodeText(result));
        }