I have this code
#!/usr/bin/perl
use strict;
my @a = ("b","a","d","c");
my %h = ("a",1,"b",2,"c",3,"d",4);
#print '"' . join('","', @a), "\"\n";
print "\n";
foreach my $key (@a) {
print '"' . $h{$key} . '",';
}
print "\n";
that outputs
"2","1","4","3",
but I would like that it just outputted
"2","1","4","3"
Notice that la...
Given the below scenario, I'm having a list of item which might be having some duplicated item.
I would like to filter the item, to print the only unique item.
Instead of duplicating a list which remove the duplicated item, I tried to insert them into std::set and std::hash_set. Nevertheless, I found no useful example to perform the op...
Hi, when i use this code to create a sha256 of a string
unsigned char hashedChars[32];
NSString *inputString;
inputString = [NSString stringWithFormat:@"hello"];
NSData * inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding];
CC_SHA256(inputData.bytes, inputData.length, hashedChars);
it returns the hash correctly, but i nee...
I have lines of code with two large arrays (so can't just write it into a hash) which I want to connect with a hash.
For example, $array1[0] becomes the key and $array2[0] becomes the value and so on to $array1[150],$array2[150].
Any ideas how I do this?
...
I have a large hash and have a subset of keys that I want to extract the values for, without having to iterate over the hash looking for each key (as I think that will take too long).
I was wondering if I can use grep to grab a file with a subset of keys? For example, something along the lines of:
my @value = grep { defined $hash{$_}{...
Good Day Sir/Madame! ^_^
I'm quite a novice when it comes to sql, so please forgive my ignorance.
I have quite a large nvarchar which I wish to pass to the HashBytes function.
I get the error:
"String or binary would be truncated.
Cannot insert the value NULL into
column 'colname', tbale 'table';
column does not allow nulls. ...
Hi,
I have a Unicode / UTF-16 encoded path. the path delimiters is U+005C '\'.
The paths are null-terminated root relative windows file system paths, e.g. "\windows\system32\drivers\myDriver32.sys"
I want to hash this path into a 64-bit unsigned integer.
It does not need to be "cryptographically sound".
The hashes should be case insens...
I'd like to represent strings as arbitrary html colors.
Example:
"blah blah" = #FFCC00
"foo foo 2" = #565656
It doesn't matter what the actual color code is, so long as it's a valid hexadecimal HTML color code and the whole spectrum is fairly well represented.
I guess the first step would be to do an MD5 on the string and then someho...
I'm using Hash::Util's lock_keys to die whenever trying to access a non-existing key in a hash.
Sometimes my hashes are deep (hash
of hashes of hashes...). Is there a
quick method to lock them all at once?
Is it possible to control the
default message upon failure (i.e.
add a Dump of the hash in which the key wasn't found)
...
I would like to print an Array of Arrays of Hashes, so I looked at perldsc, and ended up with
for my $j (0 .. $#aoaoh) {
for my $aref (@aoaoh) {
print '"' . join('","', @$aref[$j]), "\"\n";
}
}
but it doesn't work.
Does anyone know how to do this?
...
I'm using Zend_Auth with setCredentialTreatment to set the hash method and salt. I see all examples doing something like this, where the salt seems to be inserted as a text.
->setCredentialTreatment('SHA1(CONCAT(?,salt))'
but my salt is stored in the database. I could retrieve it first then use it in setCredentialTreatment but is t...
In continue to the discussion here, I'm havind some trouble with lock_hash_recurse as illustrated below:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Hash::Util qw (lock_keys);
my $hashref = {A=>1, B=>{CC=>22, DD=>33}};
lock_keys(%{$hashref}); # this is OK
Hash::Util::lock_hash_recurse(%{$hashref}); # this fails: "...
This is my array
[{:amount=>10, :gl_acct_id=>1, :alt_amount=>20}, {:amount=>20, :gl_acct_id=>2
, :alt_amount=>30}]
i want result
[{:amount => 30}] or {:amount = 30}
Any idea?
...
> Hash[:a,2,:b,4]
=> {:a=>2, :b=>4}
> Hash[:a,1]
=> {:a=>1}
> Hash[[:a,1]]
=> {}
> Hash[[[:a,1]]]
=> {:a=>1}
...
I'm curious why Object.toString() returns this:
return getClass().getName() + "@" + Integer.toHexString(hashCode());
as opposed to this:
return getClass().getName() + "@" + hashCode();
What benefits does displaying the hash code as a hex rather than a decimal buy you?
...
I have stumbled across some code that is adding strings to a List but hashing the value before adding it.
It's using an MD5 hash (MD5CryptoServiceProvider) on the string value, then adding this to the list.
Is there any value in doing this in terms of speed to find the key in the list or is this just unnecessary?
...
SHA512 is more complex than SHA1, but how much security am I losing by hashing a salted password with SHA1 compared to hashing it with 512? in terms of the time it would take for someone who has the db to crack a single password. I'm using a framework that doesn't give me easy access to SHA512, I'd have to override stuff to make it work,...
I'm using dynamic multilevel hashes from which I read data but also writes data.
A common pitfall for me is accessing non-existing keys (typos, db revisions etc.). I get undefs which propagate to other parts and cause problems. I would like to die whenever I try to read a non-existing key, but still be allowed to add new keys.
So the w...
In Ruby, I have a hash of objects. Each object has a type and a value. I am trying to design an efficient function that can get the average of the values of all of objects of a certain type within the hash.
Here is an example of how this is currently implemented:
#the hash is composed of a number of objects of class Robot (example name...
Hey.
Although this is focused on Windows Phone 7, I guess the principle is universal. I would like to have a password protected zone within my app. However, my application is completely offline and so I will have to store credential details on the phone. My initial idea is to store a hash of the password and the salt. Would this be the...