sudo -s
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
<?php | |
/** | |
* mb_str_pad | |
* | |
* @param string $input | |
* @param int $pad_length | |
* @param string $pad_string | |
* @param int $pad_type | |
* @return string |
import os | |
import json | |
import hashlib | |
import hmac | |
import base64 | |
from Crypto.Cipher import AES | |
from phpserialize import loads, dumps | |
def mcrypt_decrypt(value, iv): |
import os | |
import base64 | |
import json | |
from Crypto.Cipher import AES | |
from phpserialize import loads | |
def decrypt(payload): | |
data = json.loads(base64.b64decode(payload)) |
DO NOT use these as-is for anything important! | |
These are only very basic examples and they are missing much of what would be needed for a real-world use case. | |
These are snippets for matching encrypt and decrypt (Rijndael-128 in CBC mode with PKCS7 padding) in C#.NET, PHP, and Python. | |
I cobbled these together from various existing examples because at the time it seemed like a lot of existing examples out there for different languages/platforms did not quite match and would require quite a bit more work before they would encrypt/decrypt identically. | |
Each of these take Keys and IVs that are 16 character strings encoded in base64. |
from collections import defaultdict | |
class BadMatch(NameError): | |
"""Exception when your args don't match a pattern""" | |
pass | |
class Any(object): | |
""" | |
>>> 'wutup' == Any() | |
True |
from flask import Flask, g, request, flash, url_for, redirect, render_template, abort | |
from flaskext.jsonify import jsonify | |
from flaskext.sqlalchemy import * | |
from sqlalchemy import * | |
from pyodbc import * | |
import logging | |
DATABASE = "dsn=Foo;Trusted_Connection=Yes" | |
SECRET_KEY = "asdasdfasd1234sdagfa23asdfg123" |
$serverName = "value.cloudapp.net"; | |
$connectionInfo = array( "Database"=>"value", "UID"=>"value", "PWD"=>"value"); | |
$conn = sqlsrv_connect( $serverName, $connectionInfo); | |
if( $conn === false ) | |
{ | |
echo "Could not connect.\n"; | |
print('<pre>'); | |
die( print_r( sqlsrv_errors(), true)); | |
print('</pre>'); | |
} |
git fetch --all | |
git reset --hard origin/master | |
git pull origin master |
public class EZMap<T> { | |
public static void main(String[] args) { | |
Map<String,Object> m = hashMap( | |
bob -> 5, | |
TheGimp -> 8, | |
incredibleKoolAid -> "James Taylor", | |
heyArnold -> new Date() | |
); | |
System.out.println(m); | |
} |