package helper;
import com.yanzuoguang.util.helper.RsaHelper;
import org.junit.Test;
public class TestRsa {
@Test
public void test() throws Exception {
RsaHelper.generatorKeyPair();
}
@Test
public void rsa() {
String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3GdrIdT2lOblSalXgw4Bjnv7f2ybH+iv39QLUO4j1PeN0vacswQgmUq3KHLbxWeBqNTdsuR/G5zKv4e3raEYsAxrlHw/AJCJQOKTpYEPKLiVhNj7mqg1+I66BRwaG9AunN4bF6LfTj2wgFElVbFGbv1v8SEVDRYiUkwVsAo5JqQIDAQAB";
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 < 50; i++) {
sb.append((char) ('A' + i % 26));
}
String from = sb.toString();
String temp = RsaHelper.encryptionByPublicKey(from, publicKey);
String result = RsaHelper.decryptionByPrivateKey(temp, privateKey);
System.out.println(from);
System.out.println(result);
System.out.println(temp);
}
}
-
yanzg authored95d7f2f4