luckystar/crypto

There is no license information available for the latest version (v1) of this package.

v1 2024-04-14 15:19 UTC

This package is auto-updated.

Last update: 2025-06-14 18:04:00 UTC


README

This is a simple PHP library that provides a simple interface for encrypting and decrypting data using the OpenSSL extension.

Installation

You can install the library via Composer. Run the following command:

composer require luckystar/crypto

Function list

Function Description Example
encrypt Encrypt the given data encrypt('Hello, World!')
decrypt Decrypt the given data decrypt('b0lSSVJzeTUwZ1p4WGpmNUY0Zk55NE9janZaZWM1VVhKUEdVUDBSZWh2WT0=')
getOutput Get the output of the encryption or decryption process getOutput()
setSecretKey Set the secret key to use for encryption and decryption setSecretKey('00cccskmmx55')
setSecretIv Set the secret iv to use for encryption and decryption setSecret('00cccskmmx55')
createSecretKey Create a secret key createSecretKey()
createSecretIv Create a secret iv createSecretIv()
createRandomString Create a random string createRandomString($length)
createRandomNumber Create a random number createRandomNumber($length)
createRandomHex Create a random hex createRandomHex($length)
createUuid Create a UUID createUuid()
createRandomPassword Create a random password createRandomPassword($length = 10, $useLowercase = true, $useUppercase = true, $useNumbers = true, $useSymbols = true, $customChars = 'custom list') //!@#$%^&*()_+

Usage

use \LuckyStar\Crypto\Crypto;

// Encrypt data

echo $crypto->setSecretIv('00cccskmmx55')
	->setSecretKey('00	cccxxx55')
	->encrypt('Hello, World!')->getOutput();

// Decrypt data

echo $crypto->decrypt('b0lSSVJzeTUwZ1p4WGpmNUY0Zk55NE9janZaZWM1VVhKUEdVUDBSZWh2WT0=')->getOutput();