-3
I have a simple unescape encryptor and would like the generated NCO to be within the default code of unescape, like:
code I use:
var encN=1;
function decodeTxt(s){
var s1=unescape(s.substr(0,s.length-1));
var t='';
for(i=0;i<s1.length;i++)t+=String.fromCharCode(s1.charCodeAt(i)-s.substr(s.length-1,1));
return unescape(t);
}
function encodeTxt(s){
s=escape(s);
var ta=new Array();
for(i=0;i<s.length;i++)ta[i]=s.charCodeAt(i)+encN;
return ""+escape(eval("String.fromCharCode("+ta+")"))+encN;
}
function escapeTxt(os){
var ns='';
var t;
var chr='';
var cc='';
var tn='';
for(i=0;i<256;i++){
tn=i.toString(16);
if(tn.length<2)tn="0"+tn;
cc+=tn;
chr+=unescape('%'+tn);
}
cc=cc.toUpperCase();
os.replace(String.fromCharCode(13)+'',"%13");
for(q=0;q<os.length;q++){
t=os.substr(q,1);
for(i=0;i<chr.length;i++){
if(t==chr.substr(i,1)){
t=t.replace(chr.substr(i,1),"%"+cc.substr(i*2,2));
i=chr.length;
}}
ns+=t;
}
return ns;
}
function unescapeTxt(s){
return unescape(s);
}
function wF(s){
document.write(decodeTxt(s));
}
html:
<div id="wrap">
<form name="fA">
<div id="casa">
<input type="button" value="Encode" onclick="document.fA.c1.value=escapeTxt(document.fA.f1.value)">
<br/>
<textarea id="f1" cols=50 rows=10 wrap="off"></textarea>
</div>
<div id="casa2">
<input type="button" value="Decode" onclick="document.fA.f1.value=unescapeTxt(document.fA.c1.value)">
<br>
<textarea id="c1" cols=50 rows=10></textarea>
</div>
</form>
</div>
However, he wanted the generated code to appear along with the code below:
<script language='javascript'>
document.write( unescape( 'CODIGO GERADO AQUI' ) );
</script>
by the time you generate the code all comes out and not only Ncode without script...
is only html code
– Guilherme
Okay, and what exactly do you want to happen that actually doesn’t happen? and how hard are you having to do what you want? These things already have to be part of the question, otherwise it gets complicated. Note that it is not unwillingness to help, but is that if every question the staff has to keep trying to understand the problem, disturbs the side of those who help and yours. It is suggested to read in [Ask], and then [Edit] the question as clearly as possible.
– Bacco
when generating the code, generate inside the script, ready to copy after generating because if not I have to take the generated code and put manually inside the script <script language='javascript'> Document.write( unescape( 'generated code would be here' ) ); </script>
– Guilherme
In this case it is not only include the code when giving the escape?
– Bacco
not include the code it will be hidden...
– Guilherme
exact, and will be "undone" Ué.
– Bacco
you did not understand, type vo encodar any type of html and use them encodata in javascript unescape, if I put the javascript code at encodar time will encodar everything and I would have to put the javascript code the same way understood, i just want it to be generated with javascript...
– Guilherme
You don’t have to put it inside the meeting, right... you concatenate after it’s coded. Actually I think it’s cool that you’re doing it as an exercise, because it’s no use, but then you have to see where you invest the time. However, it would be enough to put the code inside the function Encode, as string, before the return.
– Bacco
I use this type of code from 2009 until today use, so if you can’t or can’t help me, don’t say I won’t need the code, because if I’m asking the question on the site is why I need to.
– Guilherme
Well, I’m warning you and I’m wasting my time here to help you, I’ve practically said the solution, but if you’re so sure that I’m wrong, I’ll take care of something else then. Anyway, good luck and good night.
– Bacco
"just put the code inside the function Ncode, as string, before the return" seems simple for those who understand... if I knew how to do would not be here né kkkk, but good night msm so and sorry for making you waste your precious time...
– Guilherme
It was just an orientation of how to do, maybe later someone gives an example in an official answer. As for the fact that the code does not have much use is that in practice anyone decodes the data with ease, so it does not compensate for the time you spend with this type of thing, and still ends up hindering the indexing of the content. But the code is yours, you have every right to do as you wish, I just think it’s important that you know.
– Bacco
Ta good, everyone has their opinion right, and as you said ta spending your time here atoa, do not want to argue with anyone and not even know if it is good or bad the code, just want the solution to my question if possible.
– Guilherme