Ignore:
Timestamp:
Aug 11, 2009, 9:37:27 PM (12 years ago)
Author:
Arno Wacker
Message:

This partially addresses #25

  • Added hex-string decoding and encoding to the Stream-to-String/String-to-Stream converter plug-ins.
  • Updated the converter sample to show Hex-string encoding.
Location:
trunk/CrypPlugins/StreamToStringConverter
Files:
2 edited

Legend:

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

    r419 r432  
    390390                        outputString = Encoding.Default.GetString(byteValues, 0, bytesRead);
    391391                        break;
    392                     case StreamToStringConverterSettings.EncodingTypes.Binary:
     392                    case StreamToStringConverterSettings.EncodingTypes.Base64Binary:
    393393                        outputString = Convert.ToBase64String(byteValues, 0, bytesRead);
     394                        break;
     395                    case StreamToStringConverterSettings.EncodingTypes.HexStringBinary:
     396                        outputString = convertBytesToHexString(byteValues, 0, bytesRead);
    394397                        break;
    395398                    case StreamToStringConverterSettings.EncodingTypes.Unicode:
     
    428431        }
    429432
     433        private string convertBytesToHexString(byte[] array, int start, int count)
     434        {
     435            StringBuilder sb = new StringBuilder();
     436            for (int i = start; i < (start+count); i++)
     437            {
     438               sb.Append(array[i].ToString("X2"));
     439               sb.Append(" ");
     440            }
     441            return sb.ToString();
     442        }
    430443
    431444        private void ShowStatusBarMessage(string message, NotificationLevel logLevel)
  • trunk/CrypPlugins/StreamToStringConverter/StreamToStringConverterSettings.cs

    r4 r432  
    221221        #region Public StreamToStringConverter specific properties
    222222
    223         public enum EncodingTypes { Default = 0, Binary = 1, Unicode = 2, UTF7 = 3, UTF8 = 4, UTF32 = 5, ASCII = 6, BigEndianUnicode = 7 };
     223        public enum EncodingTypes { Default = 0, Base64Binary = 1, HexStringBinary = 2, Unicode = 3, UTF7 = 4, UTF8 = 5, UTF32 = 6, ASCII = 7, BigEndianUnicode = 8 };
    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)", "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)", "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)", "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" })]
    258258        public int EncodingSetting
    259259        {
Note: See TracChangeset for help on using the changeset viewer.