@@ -140,7 +140,7 @@ public override long Position
140140
141141 private readonly bool _noSeek ;
142142
143- private string _comment ;
143+ private byte [ ] _commentRaw ;
144144
145145 private NullDecryptHelper _decryptHelper ;
146146
@@ -197,7 +197,18 @@ public string Comment
197197 {
198198 get
199199 {
200- return _comment ;
200+ return _commentRaw == null ? null : Encoding . UTF8 . GetString ( _commentRaw ) ;
201+ }
202+ }
203+
204+ /// <summary>
205+ /// Archive raw comment (binary)
206+ /// </summary>
207+ public byte [ ] CommentRaw
208+ {
209+ get
210+ {
211+ return _commentRaw ;
201212 }
202213 }
203214
@@ -220,17 +231,17 @@ public BlazerOutputStream(Stream innerStream, BlazerDecompressionOptions options
220231 if ( ! _innerStream . CanRead )
221232 throw new InvalidOperationException ( "Base stream is invalid" ) ;
222233
223- var password = options . Password ;
234+ var password = options . PasswordRaw ;
224235 _controlDataCallback = options . ControlDataCallback ?? ( ( b , o , c ) => { } ) ;
225236 _fileInfoCallback = options . FileInfoCallback ?? ( f => { } ) ;
226237 _doNotFireInfoCallbackOnOneFile = options . DoNotFireInfoCallbackOnOneFile ;
227238 _noSeek = options . NoSeek ;
228239
229240 if ( options . EncyptFull )
230241 {
231- if ( string . IsNullOrEmpty ( options . Password ) )
242+ if ( options . Password == null || options . Password . Length == 0 )
232243 throw new InvalidOperationException ( "Encryption flag was set, but password is missing." ) ;
233- _innerStream = DecryptHelper . ConvertStreamToDecyptionStream ( innerStream , options . Password ) ;
244+ _innerStream = DecryptHelper . ConvertStreamToDecyptionStream ( innerStream , options . PasswordRaw ) ;
234245 // no more password for this
235246 password = null ;
236247 }
@@ -254,7 +265,7 @@ public BlazerOutputStream(Stream innerStream, BlazerDecompressionOptions options
254265 }
255266 }
256267
257- private void InitByFlags ( BlazerFlags flags , IDecoder decoder , string password )
268+ private void InitByFlags ( BlazerFlags flags , IDecoder decoder , byte [ ] password )
258269 {
259270 if ( ( flags & BlazerFlags . IncludeHeader ) != 0 )
260271 throw new InvalidOperationException ( "Flags cannot contains IncludeHeader flags" ) ;
@@ -271,7 +282,7 @@ private void InitByFlags(BlazerFlags flags, IDecoder decoder, string password)
271282 _haveMultipleFiles = ( flags & BlazerFlags . MultipleFiles ) != 0 ;
272283 _shouldHaveComment = ( flags & BlazerFlags . IncludeComment ) != 0 ;
273284
274- if ( ! string . IsNullOrEmpty ( password ) )
285+ if ( ! ( password == null || password . Length == 0 ) )
275286 {
276287 _decryptHelper = new DecryptHelper ( password ) ;
277288 var encHeader = new byte [ _decryptHelper . GetHeaderLength ( ) ] ;
@@ -289,9 +300,9 @@ private void InitByFlags(BlazerFlags flags, IDecoder decoder, string password)
289300 ReadCommonBlocks ( ) ;
290301 }
291302
292- private void InitByHeader ( string password = null )
303+ private void InitByHeader ( byte [ ] password = null )
293304 {
294- _decryptHelper = string . IsNullOrEmpty ( password ) ? new NullDecryptHelper ( ) : new DecryptHelper ( password ) ;
305+ _decryptHelper = password == null || password . Length == 0 ? new NullDecryptHelper ( ) : new DecryptHelper ( password ) ;
295306
296307 ReadAndValidateHeader ( ) ;
297308
@@ -305,7 +316,7 @@ private void ReadCommonBlocks()
305316 var commentBytes = GetNextChunk ( true ) ;
306317 if ( _encodingType != ( byte ) BlazerBlockType . Comment )
307318 throw new InvalidOperationException ( "Invalid comment header" ) ;
308- _comment = Encoding . UTF8 . GetString ( commentBytes . Buffer , commentBytes . Offset , commentBytes . Count ) ;
319+ _commentRaw = commentBytes . ExtractToSeparateArray ( ) ;
309320 }
310321
311322 // todo: refactor this
0 commit comments