	<script src="/js/jsencrypt.min.js"></script>
	<script>
<!--
	function crypt_pw(){
		var pws = document.getElementsByClassName("password");
		if(pws == null){
			pws = document.getElementsByClassName("passwd");
		}
		if(pws == null){
			pws = document.getElementsByClassName("pw");
		}
		if(pws == null){
			window.alert("パスワード入力フィールドが存在しません");
			return false;
		}
		var rsa_pem = <?php echo "\"".preg_replace("/\n/", "", file_get_contents(__DIR__."/keys/{$PFX_KEYN}public.pem"))."\""; ?>;
		var crypt = new JSEncrypt({default_key_size: 2048});
		var slt = gen_rnd_str(8);
		crypt.setKey(rsa_pem);
		
		var cpt_pws = [];
		for(var i = 0; i < pws.length; i++){
			cpt_pws[i] = document.createElement("input");
			cpt_pws[i].setAttribute("type", "hidden");
			cpt_pws[i].setAttribute("name", pws[i].getAttribute("name"));
			cpt_pws[i].value = crypt.encrypt(slt + pws[i].value);
			pws[i].after(cpt_pws[i]);
			pws[i].setAttribute("disabled", true);
		}
		return true;
	}
	
	function gen_rnd_str(len){
		var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		var rnd_str = "";
		
		for(var i = 0; i < len; i++){
			rnd_str += chars.charAt(Math.floor(Math.random() * chars.length));
		}
		
		return rnd_str;
	}
	
	function chk_pw(){
		var pws = document.getElementsByClassName("password");
		if(pws == null){
			pws = document.getElementsByClassName("passwd");
		}
		if(pws == null){
			pws = document.getElementsByClassName("pw");
		}
		if(pws == null){
			window.alert("パスワード入力フィールドが存在しません");
			return false;
		}
		if(pws.length != 3){
			window.alert("パスワード入力フィールド数が合致しません");
			return false;
		}
		
		if(pws[1].length < 6){
			window.alert("新パスワードが短すぎます");
			return false;
		}
		else if(pws[1].value != pws[2].value){
			window.alert("新パスワードと確認用が一致しません");
			return false;
		}
		
		return crypt_pw();
	}
// -->
	</script>
