update patch 1
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class EncryptHelper
|
||||
{
|
||||
|
||||
public static function encryptLDAP($value)
|
||||
{
|
||||
$key = env('CRYPTO_KEY', ''); // Ambil kunci dari .env atau gunakan default
|
||||
$iv = env('CRYPTO_IV', ''); // Ambil IV dari .env atau gunakan default
|
||||
|
||||
try {
|
||||
$ivDecoded = base64_decode($iv);
|
||||
$cipher = openssl_encrypt($value, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $ivDecoded);
|
||||
return base64_encode($cipher);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function decryptLDAP($value)
|
||||
{
|
||||
$key = env('CRYPTO_KEY', ''); // Ambil kunci dari .env atau gunakan default
|
||||
$iv = env('CRYPTO_IV', ''); // Ambil IV dari .env atau gunakan default
|
||||
$ivDecoded = base64_decode($iv);
|
||||
|
||||
try {
|
||||
$value = base64_decode($value);
|
||||
$decrypted = openssl_decrypt($value, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $ivDecoded);
|
||||
return $decrypted;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user