apache htpasswd 사용자 암호 생 성

아파 치 웹 서버 에서 htpasswd 를 사용 하면 사용자 암호 파일 을 만 들 수 있 습 니 다. apache 문서 참조
http://httpd.apache.org/docs/2.2/programs/htpasswd.html
그 중에서 SHA 1 형식의 비밀 번 호 는 다음 과 같은 코드 로 실현 할 수 있다.


import java.io.IOException;
import java.security.NoSuchAlgorithmException;

public class ShaTest {

	public static void main(String[] args) throws NoSuchAlgorithmException, IOException {
 		String password = "123456";
		String shaPwdString = "{SHA}"
				+ new sun.misc.BASE64Encoder().encode(java.security.MessageDigest.getInstance("SHA1").digest(password.getBytes()));
		System.out.println(shaPwdString);
 	}
}

상단 코드 로 계산
명문: 123456
비밀번호: {SHA} fEqNCco3Yq9h5ZUglD3CZJT4lBs =

좋은 웹페이지 즐겨찾기