@@ -19,7 +19,7 @@ public class RsaUtils {
1919
2020 public static void main (String [] args ) throws Exception {
2121 System .out .println ("\n " );
22- RSAKeyPair keyPair = generateKeyPair ();
22+ RsaKeyPair keyPair = generateKeyPair ();
2323 System .out .println ("公钥:" + keyPair .getPublicKey ());
2424 System .out .println ("私钥:" + keyPair .getPrivateKey ());
2525 System .out .println ("\n " );
@@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
3232 /**
3333 * 公钥加密私钥解密
3434 */
35- private static void test1 (RSAKeyPair keyPair ) throws Exception {
35+ private static void test1 (RsaKeyPair keyPair ) throws Exception {
3636 System .out .println ("***************** 公钥加密私钥解密开始 *****************" );
3737 String text1 = encryptByPublicKey (keyPair .getPublicKey (), RsaUtils .SRC );
3838 String text2 = decryptByPrivateKey (keyPair .getPrivateKey (), text1 );
@@ -51,7 +51,7 @@ private static void test1(RSAKeyPair keyPair) throws Exception {
5151 * 私钥加密公钥解密
5252 * @throws Exception /
5353 */
54- private static void test2 (RSAKeyPair keyPair ) throws Exception {
54+ private static void test2 (RsaKeyPair keyPair ) throws Exception {
5555 System .out .println ("***************** 私钥加密公钥解密开始 *****************" );
5656 String text1 = encryptByPrivateKey (keyPair .getPrivateKey (), RsaUtils .SRC );
5757 String text2 = decryptByPublicKey (keyPair .getPublicKey (), text1 );
@@ -143,27 +143,27 @@ public static String encryptByPublicKey(String publicKeyText, String text) throw
143143 * @return /
144144 * @throws NoSuchAlgorithmException /
145145 */
146- public static RSAKeyPair generateKeyPair () throws NoSuchAlgorithmException {
146+ public static RsaKeyPair generateKeyPair () throws NoSuchAlgorithmException {
147147 KeyPairGenerator keyPairGenerator = KeyPairGenerator .getInstance ("RSA" );
148148 keyPairGenerator .initialize (1024 );
149149 KeyPair keyPair = keyPairGenerator .generateKeyPair ();
150150 RSAPublicKey rsaPublicKey = (RSAPublicKey ) keyPair .getPublic ();
151151 RSAPrivateKey rsaPrivateKey = (RSAPrivateKey ) keyPair .getPrivate ();
152152 String publicKeyString = Base64 .encodeBase64String (rsaPublicKey .getEncoded ());
153153 String privateKeyString = Base64 .encodeBase64String (rsaPrivateKey .getEncoded ());
154- return new RSAKeyPair (publicKeyString , privateKeyString );
154+ return new RsaKeyPair (publicKeyString , privateKeyString );
155155 }
156156
157157
158158 /**
159159 * RSA密钥对对象
160160 */
161- public static class RSAKeyPair {
161+ public static class RsaKeyPair {
162162
163163 private final String publicKey ;
164164 private final String privateKey ;
165165
166- public RSAKeyPair (String publicKey , String privateKey ) {
166+ public RsaKeyPair (String publicKey , String privateKey ) {
167167 this .publicKey = publicKey ;
168168 this .privateKey = privateKey ;
169169 }
0 commit comments