Skip to content

Instantly share code, notes, and snippets.

View konkeong's full-sized avatar

Ethan Lee Kon Keong konkeong

View GitHub Profile
@konkeong
konkeong / example.md
Created June 20, 2018 05:20 — forked from sdnts/example.md
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
@konkeong
konkeong / trim_ts.gy
Created September 15, 2015 04:31
Trim trailing whitespace in text file
import java.util.regex.*
System.setProperty('line.separator', '\n')
Set<String> setOfExtn = new HashSet<String>()
setOfExtn.add('.bat')
setOfExtn.add('.css')
setOfExtn.add('.dat')
setOfExtn.add('.dtd')
setOfExtn.add('.gradle')
@konkeong
konkeong / Aes256Cbc.java
Last active September 10, 2015 15:06
AES 256 CBC PKCS#7 in Java.
import java.security.Security;
import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@konkeong
konkeong / aestest.php
Last active August 29, 2015 14:19
AES 256 CBC PKCS#7 padding in PHP.
<?php
# http://php.net/manual/en/function.mcrypt-encrypt.php
# AES-256 is different from RIJNDAEL-256. The 256 in AES refers to the key size, where the 256 in RIJNDAEL refers to block size. AES-256 is RIJNDAEL-128 when used with a 256 bit key.
# https://gist.github.com/RiANOl/1077723
# http://en.wikipedia.org/wiki/Padding_%28cryptography%29
# PKCS#7 is described in RFC 5652.
$key_base64 = "YD/lZ0KmM1sgfoTRDq86/98jY8gwnRgSSqBwvhP74qU=";