first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
if (!function_exists('get_hash')) {
|
||||
function get_hash($PlainPassword)
|
||||
{
|
||||
$option = ['cost' => 5];
|
||||
return password_hash($PlainPassword, PASSWORD_DEFAULT, $option);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('hash_verified')) {
|
||||
function hash_verified($PlainPassword, $HashPassword)
|
||||
{
|
||||
return password_verify($PlainPassword, $HashPassword) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,4 @@
|
||||
[security]
|
||||
encryption_key=1111111111111111 ;16 digits
|
||||
iv=0899044682231054 ;16 digits
|
||||
encryption_mechanism=aes-256-cbc
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
function encrypt_url($string) {
|
||||
$output = false;
|
||||
/*
|
||||
* read security.ini file & get encryption_key | iv | encryption_mechanism value for generating encryption code
|
||||
*/
|
||||
$security = parse_ini_file("security.ini");
|
||||
$secret_key = $security["encryption_key"];
|
||||
$secret_iv = $security["iv"];
|
||||
$encrypt_method = $security["encryption_mechanism"];
|
||||
// hash
|
||||
$key = hash("sha256", $secret_key);
|
||||
// iv – encrypt method AES-256-CBC expects 16 bytes – else you will get a warning
|
||||
$iv = substr(hash("sha256", $secret_iv), 0, 16);
|
||||
//do the encryption given text/string/number
|
||||
$result = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
|
||||
$output = base64_encode($result);
|
||||
return $output;
|
||||
}
|
||||
function decrypt_url($string) {
|
||||
$output = false;
|
||||
/*
|
||||
* read security.ini file & get encryption_key | iv | encryption_mechanism value for generating encryption code
|
||||
*/
|
||||
$security = parse_ini_file("security.ini");
|
||||
$secret_key = $security["encryption_key"];
|
||||
$secret_iv = $security["iv"];
|
||||
$encrypt_method = $security["encryption_mechanism"];
|
||||
// hash
|
||||
$key = hash("sha256", $secret_key);
|
||||
// iv – encrypt method AES-256-CBC expects 16 bytes – else you will get a warning
|
||||
$iv = substr(hash("sha256", $secret_iv), 0, 16);
|
||||
//do the decryption given text/string/number
|
||||
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
|
||||
return $output;
|
||||
}
|
||||
Reference in New Issue
Block a user