Skip to content

Instantly share code, notes, and snippets.

@fankay
fankay / gist:5226527
Created March 23, 2013 05:02
常用正则表达式
常用的数字正则(严格匹配)
------------------------------
正则 含义
^[1-9]\d*$ 匹配正整数
^-[1-9]\d*$ 匹配负整数
^-?[1-9]\d*$ 匹配整数
^[1-9]\d*|0$ 匹配非负整数(正整数 + 0)
^-[1-9]\d*|0$ 匹配非正整数(负整数 + 0)
^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$ 匹配正浮点数
^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$ 匹配负浮点数
@jehrhardt
jehrhardt / KeyLengthDetector.java
Created March 15, 2013 06:23
Detect the allowed size of AES keys on the JVM. If the size is <= 256, it is limited. To fix it JCE unlimted stregth files are needed.
import javax.crypto.Cipher;
import java.security.NoSuchAlgorithmException;
public class KeyLengthDetector {
public static void main(String[] args) {
int allowedKeyLength = 0;
try {
allowedKeyLength = Cipher.getMaxAllowedKeyLength("AES");
} catch (NoSuchAlgorithmException e) {