Download the PHP package jamielsharief/encryption without Composer
On this page you can find all versions of the php package jamielsharief/encryption. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jamielsharief/encryption
More information about jamielsharief/encryption
Files in jamielsharief/encryption
Informations about the package encryption
Encryption
This library supports both asymmetric (using key pairs) and symmetric (single key) encryption. There is also a Hybrid encryption which uses both asymmetric and symmetric. Both encrypted data and signatures are returned as a Base64
encoded string.
Asymmetric Encryption
Generating Keys
To generate a key pair
Generate accepts the following options:
- size: default:4096 the size of the key
- passphrase: a password to encrypt the key with
Working with Private Keys
To create a PrivateKey
object using a private key string, pass this to the constructor
To create a PrivateKey
object by loading from a file
Things you can do with the PrivateKey
object
You can also generate a private key using the static method generate
, this will return a new PrivateKey
object.
Working with Public Keys
To create a PublicKey
object using a public key string, pass this to the constructor
To create a PublicKey
object by loading from a file
Things you can do with the PublicKey
object
Keychain
You can also manage keys with Keychain
Creating keys and adding to the Key Chain
To create a private and public key pair and add this to the Keychain
, you can pass an
email address, username, UUID or any other unique id.
You can also set an expiry date for the key
Adding
When you add a private key, the public key will be extracted and added to the same document.
To add a private or public key from a string.
Importing
When you add a private key, the public key will be extracted and added to the same document.
To import an existing public key or private/public key pair
You can also set an expiry date for the key
Get
To get a key and data
Delete
To delete a key and data
List
To get a list of keys
Symmetric Encryption
First you will need to generate a key that is 256 bit/32 bytes
To encrypt a string
To decrypt a string
Hybrid Encryption
This can only decrypt data encrypted with the Hybrid Encryption class
Hybrid encryption uses both asymmetric and symmetric encryption. With hybrid encryption there is no limit on message size.
By default encrypted/signed data is wrapped in a ENCRYPTED DATA or SIGNATURE boundary, however this can be disabled when encrypting or signing data. For example
Decryption and signature verification will remove boundaries automatically if they are found present in the data.