I have this simple decrypt function in JavaScript:  e.decrypt = function(t) {             var n, i = "", o = t.length, r = 0, s = 0;             for (r = 0; o &gt; r; r++) {                 for (n = t.substr(r, 1),                 s = 0; s &lt; e.MAP_LEN; s++) {                     if (":" == n &amp;&amp; ":|~" == t.substr(r, 3)) {                         n = "\n",                         r += 2;                         break                     }                     if (n == e.charMap[s][1]) {                         n = e.charMap[s][0];                         break                     }                 }                 i += n             }             return i         }         ,         e.MAP_LEN = 64,         e.charMap = [["A", "d"], ["B", "e"], ["C", "f"], ["D", "g"], ["E", "h"], ["F", "i"], ["G", "j"], ["H", "k"], ["I", "l"], ["J", "m"], ["K", "n"], ["L", "o"], ["M", "p"], ["N", "q"], ["O", "r"], ["P", "s"], ["Q", "t"], ["R", "u"], ["S", "v"], ["T", "w"], ["U", "x"], ["V", "y"], ["W", "z"], ["X", "a"], ["Y", "b"], ["Z", "c"], ["a", "Q"], ["b", "R"], ["c", "S"], ["d", "T"], ["e", "U"], ["f", "V"], ["g", "W"], ["h", "X"], ["i", "Y"], ["j", "Z"], ["k", "A"], ["l", "B"], ["m", "C"], ["n", "D"], ["o", "E"], ["p", "F"], ["q", "0"], ["r", "1"], ["s", "2"], ["t", "3"], ["u", "4"], ["v", "5"], ["w", "6"], ["x", "7"], ["y", "8"], ["z", "9"], ["0", "G"], ["1", "H"], ["2", "I"], ["3", "J"], ["4", "K"], ["5", "L"], ["6", "M"], ["7", "N"], ["8", "O"], ["9", "P"], ["\n", ":|~"], ["\r", ""]],         e   Then, this is the Python version that I've made:  def decryptToken(t):     n = ""     i = ""     o = len(t)     r = 0     s = 0     MAP_LEN = 64     charMap = [["A", "d"], ["B", "e"], ["C", "f"], ["D", "g"], ["E", "h"], ["F", "i"], ["G", "j"], ["H", "k"], ["I", "l"], ["J", "m"], ["K", "n"], ["L", "o"], ["M", "p"], ["N", "q"], ["O", "r"], ["P", "s"], ["Q", "t"], ["R", "u"], ["S", "v"], ["T", "w"], ["U", "x"], ["V", "y"], ["W", "z"], ["X", "a"], ["Y", "b"], ["Z", "c"], ["a", "Q"], ["b", "R"], ["c", "S"], ["d", "T"], ["e", "U"], ["f", "V"], ["g", "W"], ["h", "X"], ["i", "Y"], ["j", "Z"], ["k", "A"], ["l", "B"], ["m", "C"], ["n", "D"], ["o", "E"], ["p", "F"], ["q", "0"], ["r", "1"], ["s", "2"], ["t", "3"], ["u", "4"], ["v", "5"], ["w", "6"], ["x", "7"], ["y", "8"], ["z", "9"], ["0", "G"], ["1", "H"], ["2", "I"], ["3", "J"], ["4", "K"], ["5", "L"], ["6", "M"], ["7", "N"], ["8", "O"], ["9", "P"], ["\n", ":|~"], ["\r", ""]]      for r in range (0,o):         for s in range(0,MAP_LEN):             n = t[r:1]             if ":" == n and ":|~" == t[r:3]:                 n = "\n"                 r = r + 2                 break             if n == charMap[s][1]:                 n = charMap[s][0]                 break         i=i+n     return i   If you test with this token PEqVaW==.VdDjVbbgQU6y3fBGWfn7UDKmOXFUsLK9e5byiPSULUd= with the Javascript version, you should get this result:     9oNfXg==.fAnGfYYDaewVtCl0gCKxen4J8hpeP54zBvYVF9ce5eA=   But in Python this the output:     9   What am I doing wrong?
106
I need a good explanation (references are a plus) on Python's slice notation.   To me, this notation needs a bit of picking up.   It looks extremely powerful, but I haven't quite got my head around it.
90129
As was pointed out in  I cannot prove this, but it seems intuitively impossible.  An encryption function is supposed to obscure the plaintext to the point where no information can be obtained about it. If the underlying encryption algorithm can even be determined, that goal has not been achieved.  Is this correct? Can double-encrypting (with either the same or separate algorithms) weaken security?
41144
As made clear in update 3 on , this notation: var hash = {}; hash[X]  does not actually hash the object X; it actually just converts X to a string (via .toString() if it's an object, or some other built-in conversions for various primitive types) and then looks that string up, without hashing it, in &quot;hash&quot;. Object equality is also not checked - if two different objects have the same string conversion, they will just overwrite each other. Given this - are there any efficient implementations of hashmaps in JavaScript? (For example, the second Google result of  yields an implementation which is O(n) for any operation. Various other results ignore the fact that different objects with equivalent string representations overwrite each other.
44698
Just to establish notation with respect to the RSA protocol, let $n = pq$ be the product of two large primes and let $e$ and $d$ be the public and private exponents, respectively ($e$ is the inverse of $d \bmod \varphi(n)$).  Given a plaintext message $m$, we obtain the ciphertext $c = m^e \bmod n$; we subsequently decrypt the ciphertext by calculating $c^d \bmod n$.  Suppose I'm trying to implement RSA on a device with low computational power, and these exponentiations take too long.  I decide to make my implementation run faster by choosing small values for $e$ and $d$ (e.g. in the tens or hundreds).    Are there efficient attacks against such an implementation?
92960
As can be seen in the Mozilla changlog for JavaScript 1.7 they have added destructuring assignment. Sadly I'm not very fond of the syntax (why write a and b twice?):  var a, b;   [a, b] = f();   Something like this would have been a lot better:  var [a, b] = f();   That would still be backwards compatible. Python-like destructuring would not be backwards compatible.  Anyway the best solution for JavaScript 1.5 that I have been able to come up with is:  function assign(array, map) {     var o = Object();     var i = 0;     $.each(map, function(e, _) {         o[e] = array[i++];     });     return o; }   Which works like:  var array = [1,2]; var _ = assign[array, { var1: null, var2: null }); _.var1; // prints 1 _.var2; // prints 2   But this really sucks because _ has no meaning. It's just an empty shell to store the names. But sadly it's needed because JavaScript doesn't have pointers. On the plus side you can assign default values in the case the values are not matched. Also note that this solution doesn't try to slice the array. So you can't do something like {first: 0, rest: 0}. But that could easily be done, if one wanted that behavior.  What is a better solution?
20680
I'm developing an algorithm that takes in a vigenere cipher and produces the key length automatically. However, I'm having trouble understanding how to detect the key length when there are multiple large index of coincidences.  For example, given this cipher:  vptnvffuntshtarptymjwzirappljmhhqvsubwlzzygvtyitarptyiougxiuydtgzhhvvmum shwkzgstfmekvmpkswdgbilvjljmglmjfqwioiivknulvvfemioiemojtywdsajtwmtcgluy sdsumfbieugmvalvxkjduetukatymvkqzhvqvgvptytjwwldyeevquhlulwpkt   My algorithm produces the following indexes of coincidences for each possible key length:  KL IoC  1 0.04494435235614492    --&gt;  4%  2 0.0457833618884447     --&gt;  5%  3 0.04358853643122834    --&gt;  4%  4 0.04749622926093514    --&gt;  5%  5 0.039361207897793266   --&gt;  4%  6 0.04714370596723538    --&gt;  5%  7 0.09099225897255454    --&gt;  9%  8 0.04618589743589745    --&gt;  5%  9 0.04078047556308426    --&gt;  4% 10 0.03611528822055138    --&gt;  7% 11 0.04916033399005535    --&gt;  5% 12 0.05126633986928104    --&gt;  5% 13 0.04468864468864469    --&gt;  4% 14 0.09884877027734174    --&gt;  10% 15 0.033455433455433455   --&gt;  3% 16 0.03962703962703963    --&gt;  4% 17 0.04305498423145482    --&gt;  4% 18 0.04747474747474748    --&gt;  5% 19 0.030303030303030304   --&gt;  3% 20 0.03222222222222222    --&gt;  3% 21 0.082010582010582      --&gt;  8% 22 0.0436868686868687     --&gt;  4% 23 0.03260869565217391    --&gt;  3% 24 0.05158730158730159    --&gt;  5% 25 0.03666666666666666    --&gt;  4% 26 0.04441391941391941    --&gt;  4% 27 0.03791887125220458    --&gt;  4% 28 0.1058673469387755     --&gt;  11%   The correct key length for this cipher is indeed "7", but why is it not 14, 21, or 28? Their IoC is higher after all? What can I do within my algorithm to make it produce 7 as the key length rather than 14, 21, or 28 (or vice versa)?
69664
is there some generally available algorithm which will encrypt a short string and generate two unique keys so that any of the two can be used to decrypt the message again? It doesn't has to be "super secure".
7002
PHP's explode function returns an array of strings split on some provided substring. It will return empty strings when there are leading, trailing, or consecutive delimiters, like this: var_dump(explode('/', '1/2//3/')); array(5) {   [0]=&gt;   string(1) &quot;1&quot;   [1]=&gt;   string(1) &quot;2&quot;   [2]=&gt;   string(0) &quot;&quot;   [3]=&gt;   string(1) &quot;3&quot;   [4]=&gt;   string(0) &quot;&quot; }  Is there some different function or option or anything that would return everything except the empty strings? var_dump(different_explode('/', '1/2//3/')); array(3) {   [0]=&gt;   string(1) &quot;1&quot;   [1]=&gt;   string(1) &quot;2&quot;   [2]=&gt;   string(1) &quot;3&quot; }
2961
I have a JavaScript object like the following:  var p = {     "p1": "value1",     "p2": "value2",     "p3": "value3" };   Now I want to loop through all p elements (p1, p2, p3...) And get their keys and values. How can I do that?  I can modify the JavaScript object if necessary. My ultimate goal is to loop through some key value pairs and if possible I want to avoid using eval.
53521
What JavaScript keywords (function names, variables, etc) are reserved?
10610
I have a url like   I need a javascript function to give me the 'th' value from that.  All my urls have the same format (2 letter filenames, with .html extension).  I want it to be a safe function, so if someone passes in an empty url it doesn't break.  I know how to check for length, but I should be checking for null to right?
1900
While calculating RSA encryption key we take modulo $\varphi(n)$ rather than modulo $n$. I can’t understand why it’s done this way.
7698
Is it possible to encrypt a message in such a way that multiple keys can independently decrypt it?  In other words:  Having knowledge of $key_1, key_2 ...key_N$, which are different symmetrical keys, is it possible to generate a ciphertext that can be independently decrypted using either $key_1$ or $key_2$ or $key_N$, in such a way that the length of the ciphertext is less than directly proportional to $N$?
37301
How can I convert a JavaScript string value to be in all lower case letters? Example: &quot;Your Name&quot; to &quot;your name&quot;
98131
I am trying to simulate Deutsch's algorithm (elementary case of Deutsch-Jozsa algorithm), and I am not entirely sure how I would go about implementing the quantum oracle necessary for the algorithm to function, without defeating the purpose of the algorithm and &quot;looking&quot; at what the inputted function is, by evaluating the function.
111312
I've been trying to decrypt a message encrypted with Rabin as a challenge.  I'm very new to cryptography and these challenges so much of this is new. I've factorised n and determined that p=q which I understand to be incredibly weak.  After many hours I discovered that the proposed decryption using extended gcd will not work. A similar post on this site suggested using Tonelli Shanks to get the roots, which I have done.  It then went on to say to use Hensel to then get the original values which will then help me decode the message, however I am unfamiliar with how to implement this and so far have not been able to get a sensible solution so would like to ask for help. My values are: n = 64703986196590532550677581867968606868573389071252692910980134129544137251401009133960328088692271842214498048655106618080254509684622363068406743573918979874641476333101257493419006081088753833559346504226066744706781644205324359031963711461737816475092631177676839385116576945754784715871099567521310291121 c = 60176314581676071043291067556352196274798660837188399828657574988742539250919925123769575021091715252070984470036260674221672743791229186519807702970426856963367776191049481817101068301897617186674960557150362771617316082251276579987076557148986523477838971190589062577795308359830070072697195634741564991953 p = q = 8043878802952623586394638108236704902850439411184561583961128617599719871469109041598304494567727280429349828456316270041563810531926784203271836896365511 root0 = 2187931274452861858404184425736861076518005991476611501855956036160679792394841793895180158176546375577356726244165298846056538405976359097397665134536364  root1 = 5855947528499761727990453682499843826332433419707950082105172581439040079074267247703124336391180904851993102212150971195507272125950425105874171761829147
41585
Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused.   And now that we're here, how do they differ from a regular function?