Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27015
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Xor characters in string do not work |
| Date | Wed, 11 Mar 2015 13:09:13 +0000 |
| Organization | A noiseless patient Spider |
| Lines | 37 |
| Message-ID | <87385bisue.fsf@bsb.me.uk> (permalink) |
| References | <6485665e-6cf2-44b3-9641-6d5cd629c473@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="30260"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186ApFbm61wFJ37zO4dmJeRtI7JjmyXyC0=" |
| Cancel-Lock | sha1:0m1UFvMvoYZEOqk7+pPW1jArcMY= sha1:/xT1R74J36hYuQsotNTWtSlKp4I= |
| X-BSB-Auth | 1.3cabefd0fd7400c09d23.20150311130913GMT.87385bisue.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:27015 |
Show key headers only | View raw
jonas.thornvall@gmail.com writes:
XOR does work but...
> <SCRIPT LANGUAGE="Javascript">
> key="nyckel";
> cryptstr="text"
> j=1;
> i=1;
You'd be better off using var to declare these variables inside the
function "test" (though obviously you'll want to use parameters eventually).
> function test(){ document.write(key.charCodeAt[j]);
charCodeAt is a function -- use key.charCodeAt(j).
> document.write(cryptstr.charCodeAt[j]);
Ditto.
> cryptstr.charCodeAt[i]^= key.charCodeAt[j]^cryptstr.charCodeAt[i];
You can't assign to the result of charCodeAt. You can't even modify a
string using the special cryptstr[i] syntax. You need to build a new
string from the old one.
Finally, two ^ operations (as are hinted at here) are a no-op. I.e. an
XOR operation with some value is its own inverse.
> document.write(cryptstr[i]);
> }
> test();
> </script>
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Xor characters in string do not work jonas.thornvall@gmail.com - 2015-03-11 04:44 -0700
Re: Xor characters in string do not work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-03-11 13:09 +0000
Re: Xor characters in string do not work jonas.thornvall@gmail.com - 2015-03-11 06:49 -0700
Re: Xor characters in string do not work Martin Honnen <mahotrash@yahoo.de> - 2015-03-11 15:34 +0100
Re: Xor characters in string do not work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-12 15:43 +0100
Re: Xor characters in string do not work Scott Sauyet <scott.sauyet@gmail.com> - 2015-03-11 07:52 -0700
csiph-web