Skip to content

Instantly share code, notes, and snippets.

View dilanWijerathne's full-sized avatar

Dilan Wijerathne dilanWijerathne

  • Sri Lanka Association for Artificial Intelligence (SLAAI)
  • Colombo
View GitHub Profile
@dilanWijerathne
dilanWijerathne / AESEncryptor.php
Created July 21, 2016 08:21 — forked from Halama/AESEncryptor.php
AES Encryption with PKCS7 padding in PHP
<?php
/**
* AES Encryption with PKCS7 padding http://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7
* https://gist.github.com/RiANOl/1077723
* http://php.net/manual/en/function.mcrypt-encrypt.php
* http://stackoverflow.com/questions/7448763/proper-php-mcrypt-encryption-methods
*
* User: martinhalamicek
* Date: 7/8/13
* Time: 3:06 PM
@dilanWijerathne
dilanWijerathne / DRP Example 4.js
Created February 2, 2016 06:42 — forked from dangrossman/DRP Example 4.js
DRP Example 4.js
<div id="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>&nbsp;
<span></span> <b class="caret"></b>
</div>
<script type="text/javascript">
$(function() {
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
<?
function aes128_cbc_encrypt($key, $data, $iv) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
if(16 !== strlen($iv)) $iv = hash('MD5', $iv, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
}