Skip to content

Instantly share code, notes, and snippets.

View alikuro's full-sized avatar
🎯
Focusing

Muhamad Ali alikuro

🎯
Focusing
View GitHub Profile
@alikuro
alikuro / encrypt_aes.php
Last active April 19, 2022 06:58
Encrypt - Decrypt AES on PHP openssl vs Python Crypto
// let say key and iv is shared securely between end
// iv - encrypt method AES-256-CBC expects 16 bytes
private $secret_key = 'secret';
private $secret_iv = 'salt-secret';
function aes_encrypt($string) {
$key = hash('sha256', $this->secret_key);
$iv = substr(hash('sha256', $this->secret_iv), 0, 16);
return base64_encode(openssl_encrypt($string, 'AES-256-CBC', $key, 0, $iv));
@alikuro
alikuro / gist:432ef03b9fd572cacf1de58398d1981f
Created October 5, 2021 20:43 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@alikuro
alikuro / gist:4f1f6fa033cc721721fef8f180bb157e
Created June 29, 2018 09:37
Tjb Issue: blank page edit/ reupload pic, multiple like shadow in text while aligned, double clikc to edit not working on mobile phone
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<title>Pasang Iklan Ads Murah Bisnis Jual Beli Online - TJB.id</title>
<meta name="title" content="Pasang Iklan Ads Murah Bisnis Jual Beli Online - TJB.id"/>
<meta name="description" content="TJB.id Partner Terpercaya Beriklan Ads Murah di Indonesia - Solusi Mudah Pasang Iklan Jual Beli Online, Promosi Produk Bisnis Usaha Anda Secara Aman dan Nyaman"/>