Skip to content

fruit-php/cryptokit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CryptoKit

This package is part of Fruit Framework.

CryptoKit abstracts crypter, which encrypt and decrypt your data, and hash, which generates hashsum.

CryptoKit is still under development, not usable now.

Synopsis

Encrypt and decrypt some data

$data = 'hello world';
$crypter = new Fruit\CryptoKit\ROT13;

$encrypted = $crypter->encrypt($data);
$data = $crypter->decrypt($encrypted);

Encrypt or decrypt via stream

stream_filter_register('myfilter', 'Fruit\CryptoKit\CryptoFilter');
$f = fopen('myfile.txt', 'r');
stream_filter_append($f, 'myfilter', STREAM_FILTER_READ, [
	'crypter' => new Fruit\CryptoKit\ROT13,
	'crypt_type' => 'encrypt',
]);
$encrypted = stream_get_contents($f);
fclose($f);

Compute hashsum

$h = new Fruit\CryptoKit\Hash('md5');
$hashsum = $h->update($data)->sum();

Compute hashsum via stream

$f = fopen('myfile', 'r');
$h = new Fruit\CryptoKit\Hash('md5');
$hashsum = $h->updateStream($f)->sum();
fclose($f);

License

Any version of MIT, GPL or LGPL.

About

Cryptography helper for Fruit framework

Resources

Stars

Watchers

Forks

Packages

No packages published