Ignore:
Timestamp:
Aug 12, 2009, 9:49:16 PM (12 years ago)
Author:
Arno Wacker
Message:
  • Added octal-string decoding and encoding to the Stream-to-String/String-to-Stream converter plug-ins.
  • Updated the converter sample to show also octal-string encoding.

This closes #25.

Location:
trunk/CrypPlugins/StreamToStringConverter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/StreamToStringConverter/StreamToStringConverter.cs

    r432 r433  
    396396                        outputString = convertBytesToHexString(byteValues, 0, bytesRead);
    397397                        break;
     398                    case StreamToStringConverterSettings.EncodingTypes.OctalStringBinary:
     399                        outputString = convertBytesToOctalString(byteValues, 0, bytesRead);
     400                        break;
    398401                    case StreamToStringConverterSettings.EncodingTypes.Unicode:
    399402                        outputString = Encoding.Unicode.GetString(byteValues, 0, bytesRead);
     
    442445        }
    443446
     447        private string convertBytesToOctalString(byte[] array, int start, int count)
     448        {
     449            StringBuilder sb = new StringBuilder();
     450            for (int i = start; i < (start + count); i++)
     451            {
     452                string val = String.Format("{0,3}",Convert.ToString(array[i], 8));
     453                sb.Append(val.Replace(' ','0'));
     454                sb.Append(" ");
     455            }
     456            return sb.ToString();
     457        }
     458
    444459        private void ShowStatusBarMessage(string message, NotificationLevel logLevel)
    445460        {
  • trunk/CrypPlugins/StreamToStringConverter/StreamToStringConverterSettings.cs

    r432 r433  
    221221        #region Public StreamToStringConverter specific properties
    222222
    223         public enum EncodingTypes { Default = 0, Base64Binary = 1, HexStringBinary = 2, Unicode = 3, UTF7 = 4, UTF8 = 5, UTF32 = 6, ASCII = 7, BigEndianUnicode = 8 };
     223        public enum EncodingTypes { Default = 0, Base64Binary = 1, HexStringBinary = 2, OctalStringBinary = 3, Unicode = 4, UTF7 = 5, UTF8 = 6, UTF32 = 7, ASCII = 8, BigEndianUnicode = 9 };
    224224
    225225        /// <summary>
     
    254254        /// Encoding property used in the Settings pane.
    255255        /// </summary>
    256         [ContextMenu("Input stream encoding", "Choose the expected encoding of the input stream.", 1, DisplayLevel.Experienced, ContextMenuControlType.ComboBox, null, new string[] { "Default system encoding", "Binary data (convert to base64)", "Binary data (convert to hex-string)", "Unicode", "UTF-7", "UTF-8", "UTF-32", "ASCII", "Big endian unicode" })]
    257         [TaskPane("Input stream encoding", "Choose the expected encoding of the input stream. (The stream will be interpreted as set here, no matter what the bytes really mean)", null, 1, false, DisplayLevel.Experienced, ControlType.ComboBox, new string[] { "Default system encoding", "Binary data (convert to base64)", "Binary data (convert to hex-string)", "Unicode", "UTF-7", "UTF-8", "UTF-32", "ASCII", "Big endian unicode" })]
     256        [ContextMenu("Input stream encoding", "Choose the expected encoding of the input stream.", 1, DisplayLevel.Experienced, ContextMenuControlType.ComboBox, null, new string[] { "Default system encoding", "Binary data (convert to base64)", "Binary data (convert to hex-string)", "Binary data (convert to octal-string)", "Unicode", "UTF-7", "UTF-8", "UTF-32", "ASCII", "Big endian unicode" })]
     257        [TaskPane("Input stream encoding", "Choose the expected encoding of the input stream. (The stream will be interpreted as set here, no matter what the bytes really mean)", null, 1, false, DisplayLevel.Experienced, ControlType.ComboBox, new string[] { "Default system encoding", "Binary data (convert to base64)", "Binary data (convert to hex-string)", "Binary data (convert to octal-string)", "Unicode", "UTF-7", "UTF-8", "UTF-32", "ASCII", "Big endian unicode" })]
    258258        public int EncodingSetting
    259259        {
Note: See TracChangeset for help on using the changeset viewer.