public override void Close() { try { if (UseBaseStream) { base.Close(); } else { if (CryptoReadStream != null) { UseBaseStream = true; try { CryptoReadStream.Close(); } catch (System.Security.Cryptography.CryptographicException) { // Nothing to do. } catch (System.Exception ex) { throw ex; } UseBaseStream = false; } if (CryptoWriteStream != null) { UseBaseStream = true; try { CryptoWriteStream.Close(); } catch (System.Security.Cryptography.CryptographicException) { // Nothing to do. } catch (System.Exception ex) { throw ex; } UseBaseStream = false; } } } catch (System.Exception ex) { throw ex; } }
public override int Read(byte[] array, int offset, int count) { try { if (UseBaseStream) { return(base.Read(array, offset, count)); } else { UseBaseStream = true; int i = CryptoReadStream.Read(array, offset, count); UseBaseStream = false; return(i); } } catch (System.Exception ex) { throw ex; } }
public override int ReadByte() { try { if (UseBaseStream) { return(base.ReadByte()); } else { UseBaseStream = true; int i = CryptoReadStream.ReadByte(); UseBaseStream = false; return(i); } } catch (System.Exception ex) { throw ex; } }
protected override void Dispose(bool disposing) { try { if (disposing) { if (CryptoReadStream != null) { if (!UseBaseStream) { UseBaseStream = true; CryptoReadStream.Dispose(); CryptoReadStream = null; UseBaseStream = false; } } if (CryptoWriteStream != null) { if (!UseBaseStream) { UseBaseStream = true; CryptoWriteStream.Dispose(); CryptoWriteStream = null; UseBaseStream = false; } } if (DES != null) { DES = null; } } base.Dispose(disposing); } catch (System.Exception ex) { throw ex; } }