Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28899 > unrolled thread
| Started by | "Chris M. Thomasson" <nospam@nospam.nospam> |
|---|---|
| First post | 2015-11-20 13:00 -0800 |
| Last post | 2015-11-21 14:22 -0800 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.javascript
Online Fractal Encryption experiment in JavaScript... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-11-20 13:00 -0800
Re: Online Fractal Encryption experiment in JavaScript... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-11-21 11:35 -0800
Re: Online Fractal Encryption experiment in JavaScript... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-11-21 14:22 -0800
| From | "Chris M. Thomasson" <nospam@nospam.nospam> |
|---|---|
| Date | 2015-11-20 13:00 -0800 |
| Subject | Online Fractal Encryption experiment in JavaScript... |
| Message-ID | <n2o1mk$nv3$1@speranza.aioe.org> |
Here is a link to an online JavaScript version of my fractal encryption experiment: http://funwithfractals.atspace.cc/ffe You can simply type in some plaintext, hit encrypt and get an encrypted message along with a thumbnail bitmap of what the location in the Julia fractal actually looks like. Can you please examine the JavaScript and see if there are any terrible things I am doing? It does work for me. For instance, take the following encrypted message using the default settings: ____________________________________________ 0.4171762064590339 0.3925601542476084 0.2763103370906948 0.11458054742612529 31 5D E7 4D B7 DE FD 8C 33 FF 68 59 A1 8C DC 3B 5E D8 9F 0E 49 F8 D3 CA E1 0A CC 20 55 8E D8 80 CB 70 64 3B EC FD D2 6F 7A C9 5F F6 57 D0 C6 53 62 2D 60 AD BA 39 82 AC 46 A8 4E 0E 6C 4C 77 B5 DE 65 54 4D 50 F4 2F 95 17 65 C3 3E A5 2A 63 6F 17 ____________________________________________ Simply copy-and-paste the data between the lines above into the Ciphertext textarea and hit the decrypt button to see the message. What do you think of this? I am basically converting each byte of the plaintext into a complex number, then running a fractal iteration on them, and finally encrypting the byte using the result of said iteration via modular arithmetic.
[toc] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2015-11-21 11:35 -0800 |
| Message-ID | <8405cdb5-076f-44f7-b8ea-67c4766c0460@googlegroups.com> |
| In reply to | #28899 |
On Friday, November 20, 2015 at 3:01:23 PM UTC-6, Chris M. Thomasson wrote:
> Here is a link to an online JavaScript version of my
> fractal encryption experiment:
>
> http://funwithfractals.atspace.cc/ffe
>
>
> You can simply type in some plaintext, hit encrypt and
> get an encrypted message along with a thumbnail bitmap
> of what the location in the Julia fractal actually looks
> like. Can you please examine the JavaScript and see if
> there are any terrible things I am doing?
>
> It does work for me. For instance, take the following
> encrypted message using the default settings:
> ____________________________________________
> 0.4171762064590339 0.3925601542476084
> 0.2763103370906948 0.11458054742612529
>
> 31 5D E7 4D B7 DE FD 8C 33 FF 68 59 A1 8C DC
> 3B 5E D8 9F 0E 49 F8 D3 CA E1 0A CC 20 55 8E
> D8 80 CB 70 64 3B EC FD D2 6F 7A C9 5F F6 57
> D0 C6 53 62 2D 60 AD BA 39 82 AC 46 A8 4E 0E
> 6C 4C 77 B5 DE 65 54 4D 50 F4 2F 95 17 65 C3
> 3E A5 2A 63 6F 17
> ____________________________________________
>
> Simply copy-and-paste the data between the lines above
> into the Ciphertext textarea and hit the decrypt button
> to see the message.
>
> What do you think of this?
>
> I am basically converting each byte of the plaintext into
> a complex number, then running a fractal iteration on them,
> and finally encrypting the byte using the result of said
> iteration via modular arithmetic.
Style: The de-facto style for JS is to:
- PascalCasing for constructors (you would then not need the "::ctor" comments)
- camelCasing for methodNames and variableNames
- opening curly braces are not on a separate line
- the "m_" prefix is not used and is redundant with "this." and "foo.bar". I'm assuming you're mostly a C programmer?
CSS:
- move to external file and use <link> to reference
- de facto conventions is to place opening brace on the same line as the rule.
Script:
- move all scripts to external files
- move <script> to the bottom, right before </body>
- specify a type on every <script> tag
HTML:
- <html lang="en" dir="ltr">
Implementation:
- you use parseInt(x) in a number of places. You should specify a radix if you aren't using ECMAScript 5. If you don't, then parseInt("08") may not give you what you think it will...
- "use strict"
- you redefined "red", "green", and "blue" in your top level script
- ffe.js: methods should not be defined in a constructor. Move to the prototype
- You can save a bit of redundancy by following this convention:
function Foo(){...}
Foo.prototype = {
constructor: Foo,
method1: function(){...},
method2: function(){...}
}
- ffe_test_app.js
- this looks like a code smell:
ui_set_element_to_string("g_html_input_public_key_ymax" ...
Perhaps you should have some UI object representing your view? You could then do something along the following lines with a setter definition:
ui.public_key_xmin = foo;
and the inverse: ui_parse_string_from_element("g_html_input_ciphertext"); becomes simply a getter:
ui.ciphertext
- fractal.js
- line 225: Use '!==' to compare with '0'.
- line 236: "line" is an unused variable
- I don't see a reason why axes, point and viewport can't be standalone constructors instead of members.
mutator.js
- Strange approach:
this.m_counts = Array.apply(null, Array(256)).map(function (x, i) { return 0; });
you can use: this.m_counts = Array(256).fill(0);
same with your reset method.
See <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill>
- ui_parse.js
- as mentioned earlier, you should probably create a UI object to represent your visual interface and to manage your forms
- line 65: Use '===' to compare with '0'.
I'm sure there's more, but I'm going to stop for now.
[toc] | [prev] | [next] | [standalone]
| From | "Chris M. Thomasson" <nospam@nospam.nospam> |
|---|---|
| Date | 2015-11-21 14:22 -0800 |
| Message-ID | <n2qqrp$eqk$1@speranza.aioe.org> |
| In reply to | #28901 |
>"Michael Haufe (TNO)" wrote in message >news:8405cdb5-076f-44f7-b8ea-67c4766c0460@googlegroups.com... >>On Friday, November 20, 2015 at 3:01:23 PM UTC-6, Chris M. Thomasson >>wrote: >> Here is a link to an online JavaScript version of my >> fractal encryption experiment: >> >> http://funwithfractals.atspace.cc/ffe [...] >> What do you think of this? [...] >Style: The de-facto style for JS is to: [...] > I'm sure there's more, but I'm going to stop for now. You gave me some simply awesome advise and radically valuable information. When I get some more time, I will apply all of it for sure. Thank you very much Michael for your time. :^D
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web