0
기본적으로 Java 클라이언트와 C# 서버간에 암호화 된 데이터 흐름을 갖기 위해 노력하고 있습니다. 멀티 플랫폼 암호화 작업을 수행하는 심층적 인 작업으로 넘어 가기 전에 간단한 암호화 응용 프로그램을 만들려고 노력하고 있지만 처음부터 막혔습니다.RSA 암호화 문제
나는 다음과 같은 간단한 코드를 가지고 :
String text = "hello";
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.getPrivate();
Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] cipherData = cipher.doFinal(text.getBytes());
cipher = Cipher.getInstance("RSA/ECB/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] textData = cipher.doFinal(text.getBytes());
String decrypted = new String(textData);
System.out.println(decrypted);
예외가 발생하지 않고, 내가 해독 후 원래의 "hello"라는 텍스트를하지 않습니다. 아이디어가 있으십니까? 10 배 많은