php에서 api를 java로 변환하고 있습니다. ph1에서 sha1 메소드를 에뮬레이트하기 위해 다음 코드를 작성했습니다. 문제는 그것이 새로운 포매터 객체를 생성 할 때, 나는 그것이 내가 발견 유래를 통해보고, "sunrsasing.jar"를 찾을 수 없습니다 것을 발견, 디버깅 FileNotFoundException이를 얻을 :FileNotFoundException (sunrsasing.jar)
난그래서 JDK5 이전에 여러분이 언급 한 sun이 제공 한 별도의 jar 파일에있었습니다. 그 후 JDK는 JDK의 일부로 배포되었으며 별도의 jar로 배포되지 않았습니다. 인용문
그래서 제 질문은, 내가 &는 다른 소스에서 jar를 붙여 복사 이외의 오류를 수정할 수있는 방법이 있습니까? 그렇지 않은 경우 어디에서 찾을 수 있습니까?
private static String encryptPassword(String password)
{
String sha1 = "";
try
{
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
crypt.reset();
crypt.update(password.getBytes("UTF-8"));
sha1 = byteToHex(crypt.digest());
}
catch(NoSuchAlgorithmException e)
{
e.printStackTrace();
}
catch(UnsupportedEncodingException e)
{
e.printStackTrace();
}
return sha1;
}
private static String byteToHex(final byte[] hash)
{
Formatter formatter = new Formatter();
for (byte b : hash)
{
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
감사합니다. 그 게시물의 답은 그 트릭을하는 것처럼 보입니다. ;) – pablo
글쎄, 당신의 문제를 해결하면 정식으로 내 대답을 승인해야합니다. – Pino