개발자 Q&A

X509Certificate cert = null;

  FileInputStream fis = null;

  try {

   fis = new FileInputStream(new File("인증서파일"));

   CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");

   cert = (X509Certificate) certificateFactory.generateCertificate(fis);

  } finally {

   if (fis != null) try {

   fis.close();

   } catch(IOException ie) {}

  }

 // System.out.println(cert);

  PublicKey publicKey = cert.getPublicKey();

  System.out.println(publicKey);

  String inputStr = "abc"; // "세이프123"을 암호화한다!

  

          Cipher cipher = Cipher.getInstance("RSA");

          cipher.init(Cipher.ENCRYPT_MODE, publicKey);

          byte[] arrCipherData = cipher.doFinal(inputStr.getBytes()); // 암호화된 데이터(byte 배열)

          String strCipher = new String(arrCipherData,"euc-kr");

 

 

현재 위와같이 테스트 하고있는데 결과값이 매번 달라지는게 정상인건지...

또는 코드가 잘못된건지 질문드립니다./

 

----------------------------

 

한가지 더..

soap 웹서비스를 통해 서버에 호출할 때에 위와같은 방식으로 일부 구간을

암호화한다고 할때 인코딩을 어떤식으로 하여야하는지 알수있을까요..

 

https://okky.kr/article/415132

 

 

 

about author

PHRASE

Level 60  라이트

복리(複利)는 이 세상의 여덟 번째의 불가사의이다. -아인슈타인

댓글 ( 8)

댓글 남기기

작성