Commit 95d7f2f4 authored by yanzg's avatar yanzg

升级新版本

parent 001cb613
......@@ -2,9 +2,7 @@ package com.yanzuoguang.util.helper;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.contants.SystemContants;
import com.yanzuoguang.util.exception.CodeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yanzuoguang.util.log.Log;
import org.springframework.util.Base64Utils;
import javax.crypto.Cipher;
......@@ -34,8 +32,6 @@ import java.security.spec.X509EncodedKeySpec;
*/
public final class RsaHelper {
private static final Logger logger = LoggerFactory.getLogger(RsaHelper.class);
private static final String ALGORITHM_RSA = "RSA";
private static final String ALGORITHM_SIGN = "MD5withRSA";
......@@ -96,10 +92,10 @@ public final class RsaHelper {
byte[] keyBs = rsaPublicKey.getEncoded();
String publicKey = encodeBase64(keyBs);
logger.info("生成的公钥:\t{}", publicKey);
Log.info(RsaHelper.class, "生成的公钥:\t %s", publicKey);
keyBs = rsaPrivateKey.getEncoded();
String privateKey = encodeBase64(keyBs);
logger.info("生成的私钥:\t{}", privateKey);
Log.info(RsaHelper.class, "生成的私钥:\t %s", privateKey);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
......@@ -204,9 +200,9 @@ public final class RsaHelper {
signature.initVerify(publicKey);
signature.update(target.getBytes(SystemContants.UTF8));
if (signature.verify(decodeBase64(sign))) {
logger.info("sign true");
Log.info(RsaHelper.class, "sign true");
} else {
logger.info("sign false");
Log.info(RsaHelper.class, "sign false");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
......@@ -265,7 +261,7 @@ public final class RsaHelper {
return new String(to, SystemContants.UTF8);
} catch (Exception ex) {
throw YzgError.getRuntimeException(ex,"056",ex.getMessage());
throw YzgError.getRuntimeException(ex, "056", ex.getMessage());
}
}
......
......@@ -17,7 +17,7 @@ public class TestRsa {
String privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALcZ2sh1PaU5uVJqVeDDgGOe/t/bJsf6K/f1AtQ7iPU943S9pyzBCCZSrcoctvFZ4Go1N2y5H8bnMq/h7etoRiwDGuUfD8AkIlA4pOlgQ8ouJWE2PuaqDX4jroFHBob0C6c3hsXot9OPbCAUSVVsUZu/W/xIRUNFiJSTBWwCjkmpAgMBAAECgYBwJ18SsHWtEhmI+OdXgIjQ/J/j4Kn1jjCGdkZgV4NBrMH5TP3sdOSYDMa06TfJyCKlC6nCZ/al8BHlF/+S1VE9Mu8DRrbHAO4OJQyOEaQ64mePL6jYkhVbjr4q7kHTbsIWVu3sH9TJRa3n+lsEpEv90ri458+ofn++h+rlYKlLfQJBAPVWi1VanQlyAtGKmeA7GrxH+XYiqeq4J1suT1qUTsRwEM4RLUZcrsdGio2bVwbbyX3TB2vYdLvf1otdndKBr0MCQQC/Due/BN+B/hqOgMdW2RoHfycg/HVOp7CpsBikRUMegDQGPb6N+z/BIXkVBNHBADzaTcJh0DgSsoMRhlEdTWajAkEAq2V31/yDAytEbtGOqMmB5xG9ZNvYq2NWE2xqAdTkpnXIN75mS+bKL+vHNiDVDrSTsrSwVZaWDv7U6u5PKNZy8wJBAI/K/Af79uuy/vG5Yk2u37Q8sopU90TXWFKdwi4AIt/VxVHdLolVS0pjkumK0wLa1vHGDEHpoAoSaCrMWEghdNkCQQCUFZxSRZB8XiLtlNyT5s6UX89Ov3eZO1KmFWiXgXuZ3STr/8sDhyC9TN8uq8vK4lQiihlZQFw89LwogtJLAExc";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 500; i++) {
for (int i = 0; i < 50; i++) {
sb.append((char) ('A' + i % 26));
}
String from = sb.toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment