Thursday, September 28, 2023

Encrypt Decrypt PHP OPEN SSL PHP

 <?php
 
$simple_string = "Welcome to Jungles\n";
 
echo " Text Asli : " . $simple_string;
 
$ciphering = "AES-128-CTR";
 
$iv_length = openssl_cipher_iv_length($ciphering);
$options = 0;
 
$encryption_iv = '1234567891011121';
 
$encryption_key = "Test!234";
 
$encryption = openssl_encrypt($simple_string, $ciphering,
            $encryption_key, $options, $encryption_iv);
 
echo " 1. Encrypted String: " . $encryption . "\n";
 
$decryption_iv = '1234567891011121';
 
$decryption_key = "Test!234";
 
$decryption=openssl_decrypt ($encryption, $ciphering,
        $decryption_key, $options, $decryption_iv);
 
echo " 2. Decrypted String: " . $decryption;
 
?>

Sunday, September 17, 2023

Edit Online HTML Javascript

 1.html

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title> Custom File manager</title>

</head>

<body>

    <p><button onclick="openFile()"> Open File </button></p>

    <p><textarea id="code" cols="55" rows="15" contenteditable="true"></textarea></p>

    <p><button onclick="save()"> Save </button></p>

</body>

<script src="main.js"></script>

</html>


2. javascript

let handler;

async function openFile(){

    let [handler] = await window.showOpenFilePicker();

    let getfiles = await handler.getFile();

    let gettext = await getfiles.text();

    let textarea = document.getElementById("code");

    textarea.innerHTML = gettext;   

}


async function save(){

    const newhandler = await window.showSaveFilePicker();

    let stream = await newhandler.createWritable();

    let textarea = document.getElementById("code").value;

    await stream.write(textarea);

    await stream.close();

}

Monday, September 4, 2023

Add Date / Month / with difference Years

 <script>

Date.isLeapYear = function (year) {
    return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
};

Date.getDaysInMonth = function (year, month) {
    return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
};

Date.prototype.isLeapYear = function () {
    return Date.isLeapYear(this.getFullYear());
};

Date.prototype.getDaysInMonth = function () {
    return Date.getDaysInMonth(this.getFullYear(), this.getMonth());
};

Date.prototype.addMonths = function (value) {
    var n = this.getDate();
    this.setDate(1);
    this.setMonth(this.getMonth() + value);
    this.setDate(Math.min(n, this.getDaysInMonth()));
    return this;
};

var myDate = new Date("11/31/2012");
var result = myDate.addMonths(3);



console.log(myDate);
</script>

Set Cookie dan Remove Cookie dengan php vanilla.js

< html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta name = "viewport...