## org.h2.security
Class SecureFileStore

    java.lang.Object
      org.h2.store.FileStore
          org.h2.security.SecureFileStore

    public class SecureFileStore

extends FileStore

A file store that encrypts all data before writing, and decrypts all data after reading.

Field Summary

Fields inherited from class org.h2.store.FileStore
`empty, handler, HEADER_LENGTH, name`

Constructor Summary
`SecureFileStore(DataHandler handler, java.lang.String name, java.lang.String mode, java.lang.String cipher, byte[] key, int keyIterations)`

Method Summary
`protected byte[]` `generateSalt()` Generate the random salt bytes if required.
`protected void` `initKey(byte[] salt)` Initialize the key using the given salt.
`void` `readFully(byte[] b, int off, int len)` Read a number of bytes.
`protected void` `readFullyDirect(byte[] b, int off, int len)` Read a number of bytes without decrypting.
`void` `seek(long x)` Go to the specified file location.
`void` `setLength(long newLength)` Set the length of the file.
`void` `write(byte[] b, int off, int len)` Write a number of bytes.
`protected void` `writeDirect(byte[] b, int off, int len)` Write a number of bytes without encrypting.

Methods inherited from class org.h2.store.FileStore
`autoDelete, close, closeAndDeleteSilently, closeFile, closeSilently, getFilePointer, init, isTextMode, length, open, open, open, openFile, setCheckedWriting, stopAutoDelete, sync`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SecureFileStore

    public SecureFileStore(DataHandler handler,
                           java.lang.String name,
                           java.lang.String mode,
                           java.lang.String cipher,
                           byte[] key,
                           int keyIterations)

Method Detail

### generateSalt

    protected byte[] generateSalt()

  Description copied from class: `FileStore`
  Generate the random salt bytes if required.

  Overrides:
    `generateSalt` in class `FileStore`
  Returns:
    the random salt or the magic

### initKey

    protected void initKey(byte[] salt)

  Description copied from class: `FileStore`
  Initialize the key using the given salt.

  Overrides:
    `initKey` in class `FileStore`
  Parameters:
    `salt` - the salt

### writeDirect

    protected void writeDirect(byte[] b,
                               int off,
                               int len)

  Description copied from class: `FileStore`
  Write a number of bytes without encrypting.

  Overrides:
    `writeDirect` in class `FileStore`
  Parameters:
    `b` - the source buffer
    `off` - the offset
    `len` - the number of bytes to write

### write

    public void write(byte[] b,
                      int off,
                      int len)

  Description copied from class: `FileStore`
  Write a number of bytes.

  Overrides:
    `write` in class `FileStore`
  Parameters:
    `b` - the source buffer
    `off` - the offset
    `len` - the number of bytes to write

### readFullyDirect

    protected void readFullyDirect(byte[] b,
                                   int off,
                                   int len)

  Description copied from class: `FileStore`
  Read a number of bytes without decrypting.

  Overrides:
    `readFullyDirect` in class `FileStore`
  Parameters:
    `b` - the target buffer
    `off` - the offset
    `len` - the number of bytes to read

### readFully

    public void readFully(byte[] b,
                          int off,
                          int len)

  Description copied from class: `FileStore`
  Read a number of bytes.

  Overrides:
    `readFully` in class `FileStore`
  Parameters:
    `b` - the target buffer
    `off` - the offset
    `len` - the number of bytes to read

### seek

    public void seek(long x)

  Description copied from class: `FileStore`
  Go to the specified file location.

  Overrides:
    `seek` in class `FileStore`
  Parameters:
    `x` - the location

### setLength

    public void setLength(long newLength)

  Description copied from class: `FileStore`
  Set the length of the file. This will expand or shrink the file.

  Overrides:
    `setLength` in class `FileStore`
  Parameters:
    `newLength` - the new file size