Nextcloud PHP API (stable18)

IEncryptionModule

Interface IEncryptionModule

Tags
since
8.1.0

Table of Contents

begin()  : mixed
start receiving chunks from a file. This is the place where you can perform some initial step before starting encrypting/decrypting the chunks
decrypt()  : mixed
decrypt data
encrypt()  : mixed
encrypt data
encryptAll()  : mixed
Initial encryption of all files
end()  : string
last chunk received. This is the place where you can perform some final operation and return some remaining data if something is left in your buffer.
getDisplayName()  : string
In comparison to getKey() this function returns a human readable (maybe translated) name
getId()  : string
getUnencryptedBlockSize()  : int
get size of the unencrypted payload per block.
isReadable()  : bool
check if the encryption module is able to read the file, e.g. if all encryption keys exists
isReadyForUser()  : bool
Check if the module is ready to be used by that specific user.
needDetailedAccessList()  : bool
Does the encryption module needs a detailed list of users with access to the file? For example if the encryption module uses per-user encryption keys and needs to know the users with access to the file to encrypt/decrypt it.
prepareDecryptAll()  : bool
prepare encryption module to decrypt all files
shouldEncrypt()  : bool
should the file be encrypted or not
update()  : bool
update encrypted file, e.g. give additional users access to the file

Methods

begin()

start receiving chunks from a file. This is the place where you can perform some initial step before starting encrypting/decrypting the chunks

public begin(string $path, string $user, string $mode, array $header, array $accessList) : mixed
Parameters
$path : string

to the file

$user : string

who read/write the file (null for public access)

$mode : string

php stream open mode

$header : array

contains the header data read from the file

$accessList : array

who has access to the file contains the key 'users' and 'public'

$return array $header contain data as key-value pairs which should be written to the header, in case of a write operation or if no additional data is needed return a empty array

Tags
since
8.1.0
Return values
mixed

decrypt()

decrypt data

public decrypt(string $data, string $position) : mixed
Parameters
$data : string

you want to decrypt

$position : string

position of the block we want to decrypt

Tags
since
8.1.0
since
9.0.0

parameter $position added

Return values
mixed

decrypted data

encrypt()

encrypt data

public encrypt(string $data, string $position) : mixed
Parameters
$data : string

you want to encrypt

$position : string

position of the block we want to encrypt (starts with '0')

Tags
since
8.1.0
since
9.0.0

parameter $position added

Return values
mixed

encrypted data

encryptAll()

Initial encryption of all files

public encryptAll(InputInterface $input, OutputInterface $output) : mixed
Parameters
$input : InputInterface
$output : OutputInterface

write some status information to the terminal during encryption

Tags
since
8.2.0
Return values
mixed

end()

last chunk received. This is the place where you can perform some final operation and return some remaining data if something is left in your buffer.

public end(string $path, string $position) : string
Parameters
$path : string

to the file

$position : string

id of the last block (looks like "<Number>end")

Tags
since
8.1.0
since
9.0.0

parameter $position added

Return values
string

remained data which should be written to the file in case of a write operation

getDisplayName()

In comparison to getKey() this function returns a human readable (maybe translated) name

public getDisplayName() : string
Tags
since
8.1.0
Return values
string

getId()

public getId() : string
Tags
since
8.1.0
Return values
string

defining the technical unique id

getUnencryptedBlockSize()

get size of the unencrypted payload per block.

public getUnencryptedBlockSize([bool $signed = false ]) : int

ownCloud read/write files with a block size of 8192 byte

Parameters
$signed : bool = false
Tags
since
8.1.0

optional parameter $signed was added in 9.0.0

Return values
int

isReadable()

check if the encryption module is able to read the file, e.g. if all encryption keys exists

public isReadable(string $path, string $uid) : bool
Parameters
$path : string
$uid : string

user for whom we want to check if he can read the file

Tags
since
8.1.0
Return values
bool

isReadyForUser()

Check if the module is ready to be used by that specific user.

public isReadyForUser(string $user) : bool

In case a module is not ready - because e.g. key pairs have not been generated upon login this method can return false before any operation starts and might cause issues during operations.

Parameters
$user : string
Tags
since
9.1.0
Return values
bool

needDetailedAccessList()

Does the encryption module needs a detailed list of users with access to the file? For example if the encryption module uses per-user encryption keys and needs to know the users with access to the file to encrypt/decrypt it.

public needDetailedAccessList() : bool
Tags
since
13.0.0
Return values
bool

prepareDecryptAll()

prepare encryption module to decrypt all files

public prepareDecryptAll(InputInterface $input, OutputInterface $output[,  $user = '' ]) : bool
Parameters
$input : InputInterface
$output : OutputInterface

write some status information to the terminal during encryption

$user : = ''

for which the files should be decrypted, default = all users

Tags
since
8.2.0
Return values
bool

return false on failure or if it isn't supported by the module

shouldEncrypt()

should the file be encrypted or not

public shouldEncrypt(string $path) : bool
Parameters
$path : string
Tags
since
8.1.0
Return values
bool

update()

update encrypted file, e.g. give additional users access to the file

public update(string $path, string $uid, array $accessList) : bool
Parameters
$path : string

path to the file which should be updated

$uid : string

of the user who performs the operation

$accessList : array

who has access to the file contains the key 'users' and 'public'

Tags
since
8.1.0
Return values
bool

Search results