IEncryptedStream interface
Contents
- Introduction to the Library
- Basic support package (com.kryptel.bslx)
- Kryptel API Commons package (com.kryptel)
- Cipher package (com.kryptel.cipher)
- Compressor package (com.kryptel.compressor)
- Exceptions package (com.kryptel.exceptions)
- Hash function package (com.kryptel.hash_function)
- MAC function package (com.kryptel.mac)
- Key-related functions (com.kryptel.key)
- Silver Key engine (com.kryptel.silver_key)
- Kryptel encrypted storage (com.kryptel.storage)
- Handlers and Agents
- Names and Unique Names
- Kryptel class
- FileStorageStatistics structure
- StorageStatistics structure
- IEncryptedStorage interface
- IEncryptedStorageInfo interface
- IEncryptedObject interface
- IEncryptedStream interface
- IEncryptedFileStorage interface
- IEncryptedFileStorageInfo interface
- IFileSystemAttributes interface
- IEncryptedDirectory interface
- IEncryptedFile interface
- Example: Password storage
- File encryption examples
Declaration
package com.kryptel.storage; public interface IEncryptedStream extends AutoCloseable { void Read(byte[] buf, int start, int size) throws Exception; void Write(byte[] buf, int start, int size) throws Exception; long Size() throws Exception; void Seek(long newPos) throws Exception; void SeekEof() throws Exception; long Pos() throws Exception; boolean Eof() throws Exception; void SetEof() throws Exception; void Close() throws Exception; }
Description
This interface is used for accessing object's encrypted data stream.
Please note that Kryptel storage does not allow multiple open streams. You can have only one stream open at any given moment; the stream may be open either for reading or for writing.
Read
void Read(byte[] buf, int start, int size) throws Exception;
Reads size bytes from the data stream and stores them in buf at position start.
Write
void Write(byte[] buf, int start, int size) throws Exception;
Gets size bytes of data from buf starting at start and writes them to the data stream.
Size
long Size() throws Exception;
Returns the size of the stream.
Seek
void Seek(long newPos) throws Exception;
Moves the pointer to the specified position. This operation is allowed if the storage capabilities mask has flag Constants.ESTOR_MOVE_POINTER set.
This operation is not supported by Kryptel storage.
SeekEof
void SeekEof() throws Exception;
Moves the pointer to the end of the stream. This operation is allowed if the storage capabilities mask has flag Constants.ESTOR_MOVE_POINTER set.
This operation is not supported by Kryptel storage.
Pos
long Pos() throws Exception;
Return the current pointer position.
Eof
boolean Eof() throws Exception;
Returns true if the pointer reached the end-of-stream position.
SetEof
void SetEof() throws Exception;
Sets the end of the stream at the current position, possibly truncating it. This operation is allowed if the storage capabilities mask has flag Constants.ESTOR_TRUNCATE_STREAM set.
This operation is not supported by Kryptel storage.
Close
void Close() throws Exception;
Closes the stream. If the stream was open for writing, flushes the buffers and finalizes the stream.
Note that IEncryptedStream extends AutoCloseable interface so you can use a try argument instead of calling Close explicitly.
IEncryptedObject obj; . . . try (IEncryptedStream stream = obj.OpenStream()) { . . . }
Close will be called automatically on leaving the try block.