hash

Ideas for an efficient way of hashing a 15-puzzle state

不想你离开。 提交于 2019-12-22 08:52:19
问题 I am implementing a 15-puzzle solver by Ant Colony Optimization, and I am thinking a way of efficiently hashing each state into a number, so I waste the least amount of bytes. A state is represented by a list of 16 numbers, from 0 to 15 (0 is the hole). Like: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0] So I want to create an unique number to identify that state. I could convert all the digits to a base 16 number, but I don't think that's very efficient Any ideas?. Thanks 回答1: Your state is

how to use hashed password in impersonate of ASP.NET

别等时光非礼了梦想. 提交于 2019-12-22 08:20:09
问题 I have an ASP.NET application that requires impersonation as an administrator user. In web.config: <identity impersonate="true" userName="administrator" password="password"/> The customer complained about saving the password in clear text format. Is there a way to save the password here as hashed? 回答1: aspnet_regiis with the appropriate switch should do the trick, see this article. 来源: https://stackoverflow.com/questions/2912903/how-to-use-hashed-password-in-impersonate-of-asp-net

Reload page with different anchor

不羁岁月 提交于 2019-12-22 07:09:01
问题 Just got stuck with one problem. I have a page with Jquery UI tabs. Each tab can be accessed from different page by adding a hash tag to the link and it loads the page with the tab that I need. However, I also need to access different tabs within the same page. What I came up with is to add target="_parent" to the link with hash tag: <a href="pictures.htm#tab2" target="_parent"> and it does what I need but only in IE. It reloads the page with different hash tag but for some reason Chrome and

How can I extract values from a data.frame based on a vector in R?

£可爱£侵袭症+ 提交于 2019-12-22 06:58:22
问题 suppose I have a numeric vector like: x <- c(1.0, 2.5, 3.0) and data.frame: df<-data.frame(key=c(0.5,1.0,1.5,2.0,2.5,3.0), value=c(-1.187,0.095,-0.142,-0.818,-0.734,0.511)) df key value 1 0.5 -1.187 2 1.0 0.095 3 1.5 -0.142 4 2.0 -0.818 5 2.5 -0.734 6 3.0 0.511 I want to extract all the rows in df$key that have the same values equal to x, with result like: df.x$value [1] 0.095 -0.734 0.511 Is there an efficient way to do this please? I've tried data.frame, hash package and data.table, all

Slicing a nested hash in Perl

馋奶兔 提交于 2019-12-22 06:49:32
问题 Say I have a hash that I can index as: $hash{$document}{$word} From what I read online (although I could not find this on perlreftut, perldsc or perllol), I can slice a hash using a list if I use the @ prefix on my hash to indicate that I want the hash to return a list. However, if I try to slice my hash using a list @list : @%hash{$document}{@list} I get several "Scalar values ... better written" errors. How can I slash a nested hash in Perl? 回答1: The sigill for your hash must be @ , like so

How to write a good hashCode() for permutations?

烂漫一生 提交于 2019-12-22 06:48:55
问题 In my program, I handle a lot of lists of size n that all are permutations of [1,..., n ]. My problem is that I put these permutations in HashMap s and HashSet s, and I need a good hashCode() that avoids too many collisions. All the solutions I have thought of lead to either a lot of collisions or an overflow. How can I write a good hashCode for permutations ? 回答1: Have you tried a 'rotating hash'? You could adjust the barrel rotate amount to see if it makes much difference to the hash

How can I access SHA intrinsic?

落花浮王杯 提交于 2019-12-22 06:48:01
问题 Gprof tells me that my computationally heavy program spends most of it's time (36%) hashing using AP-Hash. I can't reduce the call count but I would still like to make it faster, can I call intrinsic SHA from a c program? Do I need the intel compiler or can I stick with gcc? 回答1: SHA instructions are now available in Goldmont architecture. It was released around September, 2016. According to the Intel Intrinsics Guide, these are the intrinsics of interest: __m128i _mm_sha1msg1_epu32 (__m128i

Why is {} used to access operator() in std::hash?

安稳与你 提交于 2019-12-22 06:46:51
问题 While reading the examples of std::hash used for std::unordered_map, I noticed that the operator() function was being accessed by {}. http://en.cppreference.com/w/cpp/utility/hash result_type operator()(argument_type const& s) const { result_type const h1 ( std::hash<std::string>{}(s.first_name) ); result_type const h2 ( std::hash<std::string>{}(s.last_name) ); return h1 ^ (h2 << 1); // or use boost::hash_combine (see Discussion) } What does the use of {} here represent? 回答1: std::hash<T> is

Changing the hashing function on a pre-existing database

亡梦爱人 提交于 2019-12-22 06:37:38
问题 I'm doing a bit of reading on hashing for passwords. I've seen that SHA-256 > MD5. This got me thinking about how an app may deal with changing from one hashing function to another. What happens if someone implements an app that hashes their passwords using MD5. They then decide that SHA-256 is the way to go. But of course the password hashes stored in the database are in MD5. What is the process for migrating the data in the database from one hashing function to another? 回答1: It is not

Is there a hash algorithm that produces a hash size of 64 bits in C#?

扶醉桌前 提交于 2019-12-22 06:32:17
问题 I need to produce a Hash value based off of a variable length string that I can store within a field no longer than 16 (due to vendor requirements). I am concatenating together several strings that are being passed through a C# script transformation in order to calculate the Hash. I am constrained by the vendor's file specification in that the output of the hash cannot be any longer than 16. Does anyone have any suggestions? As an example the string conversion of the MD5 algorith has a length