| | |
| | | return md5(reqInfo); |
| | | } |
| | | |
| | | public static String SHA1Encode(String sourceString) |
| | | { |
| | | String resultString = null; |
| | | try { |
| | | resultString = new String(sourceString); |
| | | MessageDigest md = MessageDigest.getInstance("SHA-1"); |
| | | resultString = byte2hexString(md.digest(resultString.getBytes())); |
| | | } catch (Exception localException) { |
| | | } |
| | | return resultString; |
| | | } |
| | | |
| | | |
| | | public static final String byte2hexString(byte[] bytes) |
| | | { |
| | | StringBuffer buf = new StringBuffer(bytes.length * 2); |
| | | for (int i = 0; i < bytes.length; i++) { |
| | | if ((bytes[i] & 0xFF) < 16) { |
| | | buf.append("0"); |
| | | } |
| | | buf.append(Long.toString(bytes[i] & 0xFF, 16)); |
| | | } |
| | | return buf.toString().toUpperCase(); |
| | | } |
| | | |
| | | /** |
| | | * dataFlow 对象签名 |
| | | * |
| | |
| | | |
| | | /***********************************JWT end***************************************/ |
| | | public static void main(String[] args) throws Exception { |
| | | KeyPair keyPair = genKeyPair(1024); |
| | | // KeyPair keyPair = genKeyPair(1024); |
| | | // |
| | | // //获取公钥,并以base64格式打印出来 |
| | | // PublicKey publicKey = keyPair.getPublic(); |
| | | // System.out.println("公钥:" + new String(Base64.getEncoder().encode(publicKey.getEncoded()))); |
| | | // |
| | | // //获取私钥,并以base64格式打印出来 |
| | | // PrivateKey privateKey = keyPair.getPrivate(); |
| | | // System.out.println("私钥:" + new String(Base64.getEncoder().encode(privateKey.getEncoded()))); |
| | | |
| | | //获取公钥,并以base64格式打印出来 |
| | | PublicKey publicKey = keyPair.getPublic(); |
| | | System.out.println("公钥:" + new String(Base64.getEncoder().encode(publicKey.getEncoded()))); |
| | | |
| | | //获取私钥,并以base64格式打印出来 |
| | | PrivateKey privateKey = keyPair.getPrivate(); |
| | | System.out.println("私钥:" + new String(Base64.getEncoder().encode(privateKey.getEncoded()))); |
| | | System.out.printf("passwdMd5 " + passwdMd5("wuxw2015")); |
| | | |
| | | } |
| | | } |