\CryptoManana\UtilitiesFileShredder

Class FileShredder - Utility class for file shredding.

Summary

Methods
Properties
Constants
__construct()
__destruct()
__clone()
seedRandomGenerator()
setRandomGenerator()
getRandomGenerator()
eraseFile()
$randomnessSource
No constants found
validateFileNamePath()
calculateFileSize()
writeContentToFile()
fileShredding()
$randomnessSource
N/A
No private methods found
No private properties found
N/A

Properties

$randomnessSource

$randomnessSource : \CryptoManana\Core\Abstractions\Randomness\AbstractGenerator

The pseudo-random generator service property storage.

The randomness generator.

Type

\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator — The pseudo-random generator service.

Methods

__construct()

__construct(\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator|null  $generator = null) 

Container constructor.

Parameters

\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator|null $generator

The pseudo-random generator service.

Throws

\Exception

Initialization validation.

__destruct()

__destruct() 

Container destructor.

__clone()

__clone() 

Container cloning via deep copy.

seedRandomGenerator()

seedRandomGenerator(null|integer  $seed = null) : $this

Pass a seed value to the pseudo-randomness generator service.

Parameters

null|integer $seed

Seed value in integer format or null for auto-seeding.

Throws

\Exception

Validation errors and service misuse.

Returns

$this —

The container object.

setRandomGenerator()

setRandomGenerator(\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator  $generator) : $this

Setter for the pseudo-random generator service.

Parameters

\CryptoManana\Core\Abstractions\Randomness\AbstractGenerator $generator

The pseudo-random generator service.

Returns

$this —

The container object.

eraseFile()

eraseFile(string  $filename) 

Data erasure and wiping of a file.

Parameters

string $filename

The filename and location.

Throws

\Exception

Validation errors.

validateFileNamePath()

validateFileNamePath(string  $filename) 

Internal method for location and filename validation.

Parameters

string $filename

The filename and location.

Throws

\Exception

Validation errors.

calculateFileSize()

calculateFileSize(string  $filename) : integer

Internal method for calculating the file size in bytes.

Parameters

string $filename

The filename and location.

Throws

\Exception

Validation errors.

Returns

integer —

The file size in bytes.

writeContentToFile()

writeContentToFile(string  $filename, integer  $pass, integer  $flag) : boolean

Internal method for writing of pseudo-random content to a file.

Parameters

string $filename

The filename and location.

integer $pass

The current iteration pass logic.

integer $flag

The file handle lock flag.

Throws

\Exception

Validation or filesystem errors.

Returns

boolean —

The write operation result.

fileShredding()

fileShredding(string  $filename) : boolean

Internal method for shredding the physical file based on the DOD 5220.22-M (3 passes) standard.

Parameters

string $filename

The filename and location.

Throws

\Exception

Validation or filesystem errors.

Returns

boolean —

The file shredding operation result.