mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add plate
This commit is contained in:
parent
ec0b247933
commit
ae5f8c0efe
@ -51,14 +51,17 @@ public class PatternPool {
|
|||||||
public final static Pattern UUID = Pattern.compile("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$");
|
public final static Pattern UUID = Pattern.compile("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$");
|
||||||
/** 不带横线的UUID */
|
/** 不带横线的UUID */
|
||||||
public final static Pattern UUID_SIMPLE = Pattern.compile("^[0-9a-z]{32}$");
|
public final static Pattern UUID_SIMPLE = Pattern.compile("^[0-9a-z]{32}$");
|
||||||
/** 中国车牌号码(兼容新能源车牌) */
|
|
||||||
public final static Pattern PLATE_NUMBER = Pattern.compile("^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[DF])|([DF]([A-HJ-NP-Z0-9])[0-9]{4})))|([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$");
|
|
||||||
/** MAC地址正则 */
|
/** MAC地址正则 */
|
||||||
public static final Pattern MAC_ADDRESS = Pattern.compile("((?:[A-F0-9]{1,2}[:-]){5}[A-F0-9]{1,2})|(?:0x)(\\d{12})(?:.+ETHER)", Pattern.CASE_INSENSITIVE);
|
public static final Pattern MAC_ADDRESS = Pattern.compile("((?:[A-F0-9]{1,2}[:-]){5}[A-F0-9]{1,2})|(?:0x)(\\d{12})(?:.+ETHER)", Pattern.CASE_INSENSITIVE);
|
||||||
/** 16进制字符串 */
|
/** 16进制字符串 */
|
||||||
public static final Pattern HEX = Pattern.compile("^[a-f0-9]+$", Pattern.CASE_INSENSITIVE);
|
public static final Pattern HEX = Pattern.compile("^[a-f0-9]+$", Pattern.CASE_INSENSITIVE);
|
||||||
/** 时间正则 */
|
/** 时间正则 */
|
||||||
public static final Pattern TIME = Pattern.compile("\\d{1,2}:\\d{1,2}(:\\d{1,2})?");
|
public static final Pattern TIME = Pattern.compile("\\d{1,2}:\\d{1,2}(:\\d{1,2})?");
|
||||||
|
/** 中国车牌号码(兼容新能源车牌) */
|
||||||
|
public final static Pattern PLATE_NUMBER = Pattern.compile(
|
||||||
|
//https://gitee.com/loolly/hutool/issues/I1B77H?from=project-issue
|
||||||
|
"^(([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([0-9]{5}[ABCDEFGHJK])|([ABCDEFGHJK]([A-HJ-NP-Z0-9])[0-9]{4})))|" +
|
||||||
|
"([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳使领]))$");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
/** Pattern池 */
|
/** Pattern池 */
|
||||||
|
@ -130,4 +130,9 @@ public class ValidatorTest {
|
|||||||
general = Validator.isGeneral(str, -1, 100);
|
general = Validator.isGeneral(str, -1, 100);
|
||||||
Assert.assertFalse(general);
|
Assert.assertFalse(general);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isPlateNumberTest(){
|
||||||
|
Assert.assertTrue(Validator.isPlateNumber("粤BA03205"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
|
||||||
@ -182,4 +183,18 @@ public class RSATest {
|
|||||||
|
|
||||||
Assert.assertEquals(result1, result2);
|
Assert.assertEquals(result1, result2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void exponentTest(){
|
||||||
|
String modulus = "BD99BAAB9E56B7FD85FB8BCF53CAD2913C1ACEF9063E7C913CD6FC4FEE040DA44D8" +
|
||||||
|
"ADAA35A9DCABD6E936C402D47278049638407135BAB22BB091396CB6873195C8AC8B0B7AB123" +
|
||||||
|
"C3BF7A6341A4419BDBC0EFB85DBCD9A3AD12C99E2265BDCC1197913749E2AFA568EB7623DA3A" +
|
||||||
|
"361335AA1F9FFA6E1801DDC8228AA86306B87";
|
||||||
|
String publicExponent = "65537";
|
||||||
|
RSA rsa = new RSA(new BigInteger(modulus, 16), null, new BigInteger(publicExponent));
|
||||||
|
|
||||||
|
final String encryptBase64 = rsa.encryptBase64("测试内容", KeyType.PublicKey);
|
||||||
|
Assert.assertNotNull(encryptBase64);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user