Skip to content

Instantly share code, notes, and snippets.

View wuyisheng's full-sized avatar
😃
Out sick

Yeshen wuyisheng

😃
Out sick
View GitHub Profile
@wuyisheng
wuyisheng / RsaExample.java
Last active March 25, 2019 20:23 — forked from nielsutrecht/RsaExample.java
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.security.spec.X509EncodedKeySpec;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
@wuyisheng
wuyisheng / validate_rid.js
Last active April 4, 2019 07:48 — forked from foxwoods/validate_rid.js
身份证号验证函数 | Validation function for Chinese I.D. card number
function validate_rid(id) {
// 18位身份证号
// 国家标准《GB 11643-1999》
function rid18(id) {
if(! /\d{17}[\dxX]/.test(id)) {
return false;
}
var modcmpl = function(m, i, n) { return (i + n - m % i) % i; },
f = function(v, i) { return v * (Math.pow(2, i-1) % 11); },
s = 0;