public void TestAvailable() { DocumentInputStream ostream = new DocumentInputStream(_workbook_o); DocumentInputStream nstream = new NDocumentInputStream(_workbook_n); Assert.AreEqual(_workbook_size, ostream.Available()); Assert.AreEqual(_workbook_size, nstream.Available()); ostream.Close(); nstream.Close(); try { ostream.Available(); Assert.Fail("Should have caught IOException"); } catch (InvalidOperationException) { // as expected } try { nstream.Available(); Assert.Fail("Should have caught IOException"); } catch (InvalidOperationException) { // as expected } }
private void CheckAllDirectoryContents(DirectoryEntry dir) { IEnumerator <Entry> it = dir.Entries; //foreach (Entry entry in dir) while (it.MoveNext()) { Entry entry = it.Current; if (entry is DirectoryEntry) { CheckAllDirectoryContents((DirectoryEntry)entry); } else { DocumentNode doc = (DocumentNode)entry; DocumentInputStream dis = new DocumentInputStream(doc); try { int numBytes = dis.Available(); byte[] data = new byte[numBytes]; dis.Read(data); } finally { dis.Close(); } } } }
public EncryptionInfo(DirectoryNode dir) { DocumentInputStream dis = dir.CreateDocumentInputStream("EncryptionInfo"); versionMajor = dis.ReadShort(); versionMinor = dis.ReadShort(); encryptionFlags = dis.ReadInt(); if (versionMajor == 4 && versionMinor == 4 && encryptionFlags == 0x40) { StringBuilder builder = new StringBuilder(); byte[] xmlDescriptor = new byte[dis.Available()]; dis.Read(xmlDescriptor); foreach (byte b in xmlDescriptor) builder.Append((char)b); string descriptor = builder.ToString(); header = new EncryptionHeader(descriptor); verifier = new EncryptionVerifier(descriptor); } else { int hSize = dis.ReadInt(); header = new EncryptionHeader(dis); if (header.Algorithm == EncryptionHeader.ALGORITHM_RC4) { verifier = new EncryptionVerifier(dis, 20); } else { verifier = new EncryptionVerifier(dis, 32); } } }
public void TestConstructor() { DocumentInputStream ostream = new DocumentInputStream(_workbook_o); DocumentInputStream nstream = new NDocumentInputStream(_workbook_n); Assert.AreEqual(_workbook_size, _workbook_o.Size); Assert.AreEqual(_workbook_size, _workbook_n.Size); Assert.AreEqual(_workbook_size, ostream.Available()); Assert.AreEqual(_workbook_size, nstream.Available()); }
private byte[] NextChunk() { int index = (int)(_pos >> 12); byte[] blockKey = new byte[4]; LittleEndian.PutInt(blockKey, 0, index); byte[] iv = _ag.GenerateIv(_ag.Info.Header.Algorithm, _ag.Info.Header.KeySalt, blockKey); //_cipher.Mode = CipherMode. _cipher.Key = _ag.SecretKey; _cipher.IV = iv; if (_lastIndex != index) { _stream.Skip((index - _lastIndex) << 12); } byte[] block = new byte[Math.Min(_stream.Available(), 4096)]; _stream.ReadFully(block); _lastIndex = index + 1; throw new NotImplementedException(); //return _cipher.doFinal(block); Leon }