Provides easy to use classes and traits for cryptographic functions using
openssl_*
. Intended to be compatible with JSCrypt & SubtleCrypto / JWK
- PHP >= 7
- openssl
- Best if imported as a Git submodule using
git submodule add git://github.com/shgysk8zer0/phpcrypt.git
- Use
spl_autoload
for autoloading
<?php
set_include_path('/path/to/classes_dir/' . PATH_SEPARATOR . get_include_path());
spl_autoload_register('spl_autoload');
$keys = new \shgysk8zer0\PHPCrypt\KeyPair(PUBLIC_KEY, PRIVATE_KEY, PASSWORD);
$encrypted = $keys->encrypt(MESSAGE);
$decrypted = $keys->decrypt($encrypted);
$sig = $keys->sign($encrypted);
$valid = $keys->verify($encrypted, $sig);
$matches = MESSAGE === $decrypted;