My hash contains key that has multiple values(contains duplicates) and keep the value unique so my output looks.  $VAR1 = { 'One' =&gt; ['code','links','links'], 'Two' =&gt; ['indent','indent'], };   I need the hash output as below  `$VAR1 = { 'One' =&gt; ['code','links'], 'Two' =&gt; ['indent'], };`   Please advice, Thanks.
33672
I have an array in Perl:  my @my_array = ("one","two","three","two","three");   How do I remove the duplicates from the array?
104858
Let's say I start with a particular 256 bit value. Call this $v$. I then hash that value, and get another 256 bit value. Call this $\text{SHA256}(v)$. I take this value and get another 256 bit value. Call this $\text{SHA256}^2(v)$. More generally, let's call the result of hashing $v$ repeatedly $n$ times $\text{SHA256}^n(v)$.  Now my question is, how big will $n$ be, such that $\text{SHA256}^n(v) = v$?  It would seem to me, that if it's a giant sort of permutation, $n$ would have to be $2^{256}$, is that correct? Is that provable, or is there any information on this? (Just curiosity, really.)  Another question I had was, do all 256 bit strings have unique SHA256 values, and is there a way to show that? (Or, stated differently, can it be shown that there are no SHA-256 collisions in the language of all "256 bit strings"?)
29869
In php, I often need to map a variable using an array ... but I can not seem to be able to do this in a one liner. c.f. example:  // the following results in an error: echo array('a','b','c')[$key];  // this works, using an unnecessary variable: $variable = array('a','b','c'); echo $variable[$key];   This is a minor problem, but it keeps bugging every once in a while ... I don't like the fact, that I use a variable for nothing ;)
113295
I am trying the contents of an array into a file with each element of the array in a new line in the file.  IFS=$'\n'    echo "${mtches[@]}" &gt; sample1.txt     The content of mtches is "qwe" and " asd". But the sample1.txt file contains qwe asd in a single line. Why is it not taking IFS value into the picture?
25847
Is there any way to use a constant as a hash key?  For example:  use constant X =&gt; 1;  my %x = (X =&gt; 'X');   The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.
104837
Any decent hash algorithm will produce basically "random like" values for any given input including the empty input.  For example MD5 produces d41d8cd98f00b204e9800998ecf8427e on an empty input.  I wonder, however, why the MD5 algorithm wasn't defined to have a final step where the output is XORed with d41d8cd98f00b204e9800998ecf8427e. This should not affect the cryptographic strength of the hash algorithm, and it would have the convenient property that a hash of all zeros represented a zero input.  Would it simply just because adding that step would slow the hash down a bit?
7821
I'm looking for an explanation of how a hash table works - in plain English for a simpleton like me!   For example, I know it takes the key, calculates the hash (I am looking for an explanation how) and then performs some kind of modulo to work out where it lies in the array where the value is stored, but that's where my knowledge stops.  Could anyone clarify the process?  Edit: I'm not asking specifically about how hash codes are calculated, but a general overview of how a hash table works.
9730
How can I remove duplicate values from an array in PHP?
4243
I want to find the md5 hash of the string "a", but running echo "a" | md5sum gives me another hash than what I get if I search the internet (for example using  or ).  Running echo "a" | md5sum gives me "60b725f10c9c85c70d97880dfe8191b3", but it should be "0cc175b9c0f1b6a831c399e269772661".  If I make a reverse hash lookup for "60b725f10c9c85c70d97880dfe8191b3", I do however get "a".
8481
What is the easiest way to encode a PHP string for output to a JavaScript variable?  I have a PHP string which includes quotes and newlines.  I need the contents of this string to be put into a JavaScript variable.  Normally, I would just construct my JavaScript in a PHP file, à la:  &lt;script&gt;   var myvar = "&lt;?php echo $myVarValue;?&gt;"; &lt;/script&gt;   However, this doesn't work when $myVarValue contains quotes or newlines.
79644
So I'm checking the md5 hash of my files with this as my output:  657cf4512a77bf47c39a0482be8e41e0  ./dupes2.txt 657cf4512a77bf47c39a0482be8e41e0  ./dupes.txt 8d60a927ce0f411ec94ac26a4785f749  ./derpina.txt 15f63928b8a1d5337137c38b5d66eed3  ./foo.txt 8d60a927ce0f411ec94ac26a4785f749  ./derp.txt   However, after running find . -type f -exec md5sum '{}' ';' | uniq -w 33 to find the unique hashes I get this:  657cf4512a77bf47c39a0482be8e41e0  ./dupes2.txt 8d60a927ce0f411ec94ac26a4785f749  ./derpina.txt 15f63928b8a1d5337137c38b5d66eed3  ./foo.txt 8d60a927ce0f411ec94ac26a4785f749  ./derp.txt   From my understanding, only one of either derpina.txt or derp.txt should be showing up since their hashes are the same. Am I missing something? Can anyone enlighten me as to why it outputs like this?
58889
I am learning Perl, so please bear with me for this noob question.   How do I repeat a character n times in a string?   I want to do something like below:  $numOfChar = 10;  s/^\s*(.*)/' ' x $numOfChar$1/;
1921
PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fairly efficient way to check if an array contains only numeric keys? Basically, I want to be able to differentiate between this: $sequentialArray = [     'apple', 'orange', 'tomato', 'carrot' ];  and this: $assocArray = [     'fruit1' =&gt; 'apple',     'fruit2' =&gt; 'orange',     'veg1' =&gt; 'tomato',     'veg2' =&gt; 'carrot' ];
64488
I am trying to parse url-encoded strings that are made up of key=value pairs separated by either &amp; or &amp;amp;.   The following will only match the first occurrence, breaking apart the keys and values into separate result elements:  var result = mystring.match(/(?:&amp;|&amp;amp;)?([^=]+)=([^&amp;]+)/)   The results for the string '1111342=Adam%20Franco&amp;348572=Bob%20Jones' would be:  ['1111342', 'Adam%20Franco']   Using the global flag, 'g', will match all occurrences, but only return the fully matched sub-strings, not the separated keys and values:  var result = mystring.match(/(?:&amp;|&amp;amp;)?([^=]+)=([^&amp;]+)/g)   The results for the string '1111342=Adam%20Franco&amp;348572=Bob%20Jones' would be:  ['1111342=Adam%20Franco', '&amp;348572=Bob%20Jones']   While I could split the string on &amp; and break apart each key/value pair individually, is there any way using JavaScript's regular expression support to match multiple occurrences of the pattern /(?:&amp;|&amp;amp;)?([^=]+)=([^&amp;]+)/ similar to PHP's preg_match_all() function?  I'm aiming for some way to get results with the sub-matches separated like:  [['1111342', '348572'], ['Adam%20Franco', 'Bob%20Jones']]   or   [['1111342', 'Adam%20Franco'], ['348572', 'Bob%20Jones']]
34544
I was wondering if there is a cryptographic hash where the resulting hash is identical to the input for the hash function.  If this is the case, would it be a weakness in the hashing function?
17676
Is every output of a hash function (e.g. SHA1, MD5, etc) guaranteed to be possible, or, conversely, are there any output values that cannot possibly be created from any input? In other words, are hash functions surjective?  If so, what guarantees this? If not, is it possible to discover such impossible outputs via an attack faster than brute force?
58273
I know that php has md5(), sha1(), and the hash() functions, but I want to create a hash using the MySQL PASSWORD() function.  So far, the only way I can think of is to just query the server, but I want a function (preferably in php or Perl) that will do the same thing without querying MySQL at all.  For example:  MySQL hash -> 464bb2cb3cf18b66  MySQL5 hash -> *01D01F5CA7CA8BA771E03F4AC55EC73C11EFA229  Thanks!