Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 1.33 KB

Encrypter.md

File metadata and controls

26 lines (22 loc) · 1.33 KB

Encrypter Class (available in HPFv3 Only)

This Encrypter class has 3 small methods to Generate Initial Vector, Encrypt String and Decrypt String. The encryption rely on AES-CBC encryption via PHPSecLib. PHPSecLib one of best encryption library which is has a complex mechanism to encrypt anything!

Methods Directory

  • Encrypter::CreateIv()
  • Encrypter::AESEncrypt()
  • Encrypter::AESDecrypt()

Encrypter::CreateIv() :static method

This method will return random byte.
This random byte will be use as Initial Vector (IV) to encrypt or decrypt string.

$block = Encrypter::CreateIv();

Encrpter::AESEncrypt(@param1, @param2, @param3) :static method

@param1:string -> String to encrypt
@param2:string -> String key, 16 or 32 character.
@param3:byte -> Byte of initial value, can use Encrypter::CreateIv()
This method will return encrypted string as byte.

Encrypter::AESDecrypt(@param1, @param2, @param3) :static method

@param1:byte -> Byte of encrypted string. Can use value from Encrypter::AESEncrypt()
@param2:string -> String of key, 16 or 32 character. Must use the same key while encrypting string.
@param3:byte -> Byte of initial value. Must use the same block byte while encrypting string.
This method will return decrypted byte as string.