//----------------------------------------
//文字列暗号化/復号化用クラス
//----------------------------------------
var cript = new function()
{
	//文字列暗号化
	this.encript = function(str)
	{
		var baseStr = str;
		
		//@を[at]に置換
		baseStr = baseStr.replace(/\@/g,"{at}");
		
		//.を[dot]に置換
		baseStr = baseStr.replace(/\./g,"{dot}");
		
		//-を[hyphen]に置換
		baseStr = baseStr.replace(/\-/g,"{hyphen}");
		
		//_を[ubar]に置換
		baseStr = baseStr.replace(/\_/g,"{ubar}");
		
		var retStr = "";
		for(var i=0; i<baseStr.length; i++)
		{
			retStr += String.fromCharCode(baseStr.charCodeAt(i) +1);
		}
		
		return retStr;
	}
	
	//文字列復号化
	this.decript = function(str)
	{		
		var retStr = "";
		
		for(var i=0; i<str.length; i++)
		{
			//console.log("a : " + str.charAt(i));
			var b = str.charCodeAt(i);
			//console.log("b : " + b);
			var c = String.fromCharCode(str.charCodeAt(i) -1)
			//console.log("c : " + c);
			retStr += c;
		}
		
		//[at]を置換
		retStr = retStr.replace(/\{at\}/g,"@");
		
		//[dot]を置換
		retStr = retStr.replace(/\{dot\}/g,".");
		
		//[hyphen]を置換
		retStr = retStr.replace(/\{hyphen\}/g,"-");
		
		//[ubar]を置換
		retStr = retStr.replace(/\{ubar\}/g,"_");
		
		return retStr;
	}
}

//プロトタイプ拡張
String.prototype.encript = function(){
	return cript.encript(this);
}
String.prototype.decript = function(){
	return cript.decript(this);
}

