Search Results

Search found 3659 results on 147 pages for 'sorted hash'.

Page 24/147 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Creating a unique key based on file content in python

    - by Cawas
    I got many, many files to be uploaded to the server, and I just want a way to avoid duplicates. Thus, generating a unique and small key value from a big string seemed something that a checksum was intended to do, and hashing seemed like the evolution of that. So I was going to use hash md5 to do this. But then I read somewhere that "MD5 are not meant to be unique keys" and I thought that's really weird. What's the right way of doing this? edit: by the way, I took two sources to get to the following, which is how I'm currently doing it and it's working just fine, with Python 2.5: import hashlib def md5_from_file (fileName, block_size=2**14): md5 = hashlib.md5() f = open(fileName) while True: data = f.read(block_size) if not data: break md5.update(data) f.close() return md5.hexdigest()

    Read the article

  • Question about the mathematical properties of hashes

    - by levand
    Take a commonly used binary hash function - for example, SHA-256. As the name implies, it outputs a 256 bit value. Let A be the set of all possible 256 bit binary values. A is extremely large, but finite. Let B be the set of all possible binary values. B is infinite. Let C be the set of values obtained by running SHA-256 on every member of B. Obviously this can't be done in practice, but I'm guessing we can still do mathematical analysis of it. My Question: By necessity, C ? A. But does C = A?

    Read the article

  • Ruby: rules for implicit hashes

    - by flyer
    Why second output shows me only one element of Array? Is it still Array or Hash already? def printArray(arr) arr.each { | j | k, v = j.first printf("%s %s %s \n", k, v, j) } end print "Array 1\n" printArray( [ {kk: { 'k1' => 'v1' }}, {kk: { 'k2' => 'v2' }}, {kk: { 'k3' => 'v3' }}, ]) print "Array 2\n" printArray( [ kk: { 'k1' => 'v1' }, kk: { 'k2' => 'v2' }, kk: { 'k3' => 'v3' }, ]) exit # Output: # # Array 1 # kk {"k1"=>"v1"} {:kk=>{"k1"=>"v1"}} # kk {"k2"=>"v2"} {:kk=>{"k2"=>"v2"}} # kk {"k3"=>"v3"} {:kk=>{"k3"=>"v3"}} # Array 2 # kk {"k3"=>"v3"} {:kk=>{"k3"=>"v3"}}

    Read the article

  • Accessing a nested hash in a controller

    - by Magicked
    I have the following (snipped) parameters passed into my controller. Parameters: {"commit"=>"OK", "action"=>"set_incident_incident_status_id", "id"=>"1", "controller"=>"incidents", "incident"=>{"incident_status_id"=>"1"}} I know that if I want to select the incident, I can do: @incident = Incident.find(params[:id]) How do I access the "incident"={"incident_status_id"="1"}? I thought to try something like: @incident_status = IncidentStatus.find(params[:incident => :incident_status_id]) But that didn't work. I'm assuming it's just a syntax problem at this point, and I haven't found a solution yet. Any help would be much appreciated!

    Read the article

  • Do encryption algorithms provide really unique results?

    - by Mikulas Dite
    I was wondering whether md5, sha1 and anothers return unique values. For example, sha1() for test returns a94a8fe5ccb19ba61c4c0873d391e987982fbbd3, which is 40 characters long. So, sha1 for strings larger than 40 chars must be the same (of course it's scrambled, because the given input may contain whitespaces and special chars etc.). Due to this, when we are storing users' passwords, they can enter either their original password or some super-long one, which nobody knows. Is this right, or do these hash algorithms provide really unique results - I'm quite sure it's hardly possible.

    Read the article

  • password/login system in php

    - by Jonathan
    For a login system in php would this be a suitable outline of how it would work: users types in username and password, clicks login button. Checks if user exists in database, if it does, then retrieve the salt for that user hash the password and salt (would this be done on the client or server side? I think client side would be better, but php is server side so how would you do this?) check value against value in database, if the values match then user has typed in correct password and they are logged in.

    Read the article

  • Population count of rightmost n integers

    - by Jason Baker
    I'm implementing Bagwell's Ideal Hash Trie in Haskell. To find an element in a sub-trie, he says to do the following: Finding the arc for a symbol s, requires ?nding its corresponding bit in the bit map and then counting the one bits below it in the map to compute an index into the ordered sub-trie. What is the best way to do this? It sounds like the most straightforward way of doing this is to select the bits below that bit and do a population count on the resulting number. Is there a faster or better way to do this?

    Read the article

  • Creating a simple java hash server

    - by Blankman
    Is it possible to create a simple server in Java that returns a response based on a given key? So it would be a simple program, that stores a hashmap and returns the result based on a key provided by the client. What would be the fasted implementation, to have it over HTTP or a socket? The client will be a web based application.

    Read the article

  • Hashing and salting values

    - by Avanst
    I am developing a small web app that internally authenticates users. Once the user is authenticated my web app then passes some information such as userID and Person's name to a third party web application. The third party developer is suggesting that we hash and salt the values. Forgive my ignorance, but what exactly does that mean? I am writing the app in Java. So what I am planning on doing is hashing the userID, Person's name, and some Math.random() value as the salt with Apache Commons Digest Utils SHA512 and passing that hashed string along with the userID and person's name. Is that the standard practice? I should be passing the third party the salt as well correct?

    Read the article

  • How can I map URLs to filenames with perl?

    - by eugene y
    In a simple webapp I need to map URLs to filenames or filepaths. This app has a requirement that it can depend only on modules in the core Perl ditribution (5.6.0 and later). The problem is that filename length on most filesystems is limited to 255. Another limit is about 32k subdirectories in a single folder. My solution: my $filename = $url; if (length($filename) > $MAXPATHLEN) { # if filename longer than 255 my $part1 = substr($filename, 0, $MAXPATHLEN - 13); # first 242 chars my $part2 = crypt(0, substr($filename, $MAXPATHLEN - 13)); # 13 chars hash $filename = $part1.$part2; } $filename =~ s!/!_!g; # escape directory separator Is it reliable ? How can it be improved ?

    Read the article

  • Ruby hash value truthiness and symbols

    - by John Topley
    Could somebody please explain why the variable named foo remains true in the code below, even though it's set to false when the method is called? And why the symbol version behaves as expected? def test(options = {}) foo = options[:foo] || true bar = options[:bar] || :true puts "foo is #{foo}, bar is #{bar}" end >> test(:foo => false, :bar => :false) foo is true, bar is false I've only tried this using Ruby 1.8.7.

    Read the article

  • Set a session hash outside of RoR program?

    - by Sindri Guðmundsson
    Hi, I have had my new rails program up for a few days now. I'm running it on Ubuntu 10.4 with apache2 in another location than the website it's made for (it's a standalone database application for physiotherapists). The people I made it for now want me to deploy it to the public part of their website, only with one change. Those who open it via the link in the public-part should not be able to click one button! I was thinking of doing something like this in my view: <% if session[:inside]%> <%=button_to 'Sækja mælitæki', @link_to_mt%> <%end%> How could I set session[:inside] only to true if the program was started from within the private part of the webpage? I thought of creating two new actions, the other would set session[:inside] to true and the other to false, but that seems to me like a security risk, is it not? BR, Sindri

    Read the article

  • Merging hashes into one hash in perl

    - by Nick
    how do I get this: $VAR1 = { '999' => { '998' => [ '908', '906', '0', '998', '907' ] } }; $VAR1 = { '999' => { '991' => [ '913', '920', '918', '998', '916', '919', '917', '915', '912', '914' ] } }; $VAR1 = { '999' => { '996' => [] } }; $VAR1 = { '999' => { '995' => [] } }; $VAR1 = { '999' => { '994' => [] } }; $VAR1 = { '999' => { '993' => [] } }; $VAR1 = { '999' => { '997' => [ '986', '987', '990', '984', '989', '988' ] } }; $VAR1 = { '995' => { '101' => [] } }; $VAR1 = { '995' => { '102' => [] } }; $VAR1 = { '995' => { '103' => [] } }; $VAR1 = { '995' => { '104' => [] } }; $VAR1 = { '995' => { '105' => [] } }; $VAR1 = { '995' => { '106' => [] } }; $VAR1 = { '995' => { '107' => [] } }; $VAR1 = { '994' => { '910' => [] } }; $VAR1 = { '993' => { '909' => [] } }; $VAR1 = { '993' => { '904' => [] } }; $VAR1 = { '994' => { '985' => [] } }; $VAR1 = { '994' => { '983' => [] } }; $VAR1 = { '993' => { '902' => [] } }; $VAR1 = { '999' => { '992' => [ '905' ] } }; to this: $VAR1 = { '999:' => [ { '992' => [ '905' ] }, { '993' => [ { '909' => [] }, { '904' => [] }, { '902' => [] } ] }, { '994' => [ { '910' => [] }, { '985' => [] }, { '983' => [] } ] }, { '995' => [ { '101' => [] }, { '102' => [] }, { '103' => [] }, { '104' => [] }, { '105' => [] }, { '106' => [] }, { '107' => [] } ] }, { '996' => [] }, { '997' => [ '986', '987', '990', '984', '989', '988' ] }, { '998' => [ '908', '906', '0', '998', '907' ] }, { '991' => [ '913', '920', '918', '998', '916', '919', '917', '915', '912', '914' ] } ]}; in Perl?

    Read the article

  • How do I quiet image_submit_tag from params hash?

    - by Alan S
    Does anyone know how to eliminate the x and y params when you use image_submit_tag with a get method? I have a simple search form, and using get to pass the value in the url. When I use image_submit_tag, it also appends the x and y coords, so I get urls like http://example.com?q=somesearchterm&x=15&y=12 When I have used submit_tag, I can use the :name = nil attribute (was in one of Ryan Bates' Railscasts), but it doesn't seem to work for image_submit_tag. Granted it doesn't affect functionality, but I don't need them and would like them quieted.

    Read the article

  • What hash/map based programming language exist?

    - by Davorak
    Much like lisp is often considered a list based programming language what languages are considered map based? I remember reading about one a few years back, but can not longer find a reference to it. It looked something like: [if:test then:<code> else:<more code>] edit: and more where quoted code blocks which would be conditional evaluated. In this fashion if/cond and others would not be special form as they are in lisp/scheme.

    Read the article

  • Birthday effect - clarification needed plz.

    - by Mark
    Please help interpret the Birthday effect as described in Wikipedia: A birthday attack works as follows: 1) Pick any message m and compute h(m). 2) Update list L. Check if h(m) is in the list L. 3) if (h(m),m) is already in L, a colliding message pair has been found. else save the pair (h(m),m) in the list L and go back to step 1. From the birthday paradox we know that we can expect to find a matching entry, after performing about 2^(n/2) hash evaluations. Does the above mean 2^(n/2) iterations through the above entire loop (i.e. 2^(n/2) returns to step 1), OR does it mean 2^(n/2) comparisons to individual items already in L.

    Read the article

  • Can someone please clarify the Birthday Effect for me?

    - by Mark
    Please help interpret the Birthday effect as described in Wikipedia: A birthday attack works as follows: Pick any message m and compute h(m). Update list L. Check if h(m) is in the list L. if (h(m),m) is already in L, a colliding message pair has been found. else save the pair (h(m),m) in the list L and go back to step 1. From the birthday paradox we know that we can expect to find a matching entry, after performing about 2^(n/2) hash evaluations. Does the above mean 2^(n/2) iterations through the above entire loop (i.e. 2^(n/2) returns to step 1), OR does it mean 2^(n/2) comparisons to individual items already in L.

    Read the article

  • When should I define an hash code function for my types?

    - by devoured elysium
    Is there any other reason for implementing an hash code function for my types other than allowing for good use of hash tables? Let's say I am designing some types that I intend to use internally. I know that types are "internal" to the system, and I also know I will never use those types in hash tables. In spite of this, I decide I will have to redefine the equals() method. Theory says I should also redefine the hash code method, but I can't see any reason why, in this case, I should do it. Can anyone point me out any other reason? This question can be rephrased to : in which situations should we implement a hash code method in our types. PS : I am not asking how to implement one. I am asking when.

    Read the article

  • Union of two or more (hash)maps

    - by javierfp
    I have two Maps that contain the same type of Objects: Map<String, TaskJSO> a = new HashMap<String, TaskJSO>(); Map<String, TaskJSO> b = new HashMap<String, TaskJSO>(); public class TaskJSO { String id; } The map keys are the "id" properties. a.put(taskJSO.getId(), taskJSO); I want to obtain a list with: all values in "Map b" + all values in "Map a" that are not in "Map b". What is the fastest way of doing this operation? Thanks EDIT: The comparaison is done by id. So, two TaskJSOs are considered as equal if they have the same id (equals method is overrided). My intention is to know which is the fastest way of doing this operation from a performance point of view. For instance, is there any difference if I do the "comparaison" in a map (as suggested by Peter): Map<String, TaskJSO> ab = new HashMap<String, TaskJSO>(a); ab.putAll(b); ab.values() or if instead I use a set (as suggested by Nishant): Set s = new Hashset(); s.addAll(a.values()); s.addAll(b.values());

    Read the article

  • What would a compress method do in a hash table?

    - by Bradley Oesch
    For an assignment I have to write the code for a generic Hash Table. In an example Put method, there are two lines: int hash = key.hashCode(); // get the hashcode of the key int index = compress(hash); // compress it to an index I was of the understanding that the hashCode method used the key to return an index, and you would place the key/value pair in the array at that index. But here we "compress" the hash code to get the index. What does this method do? How does it "compress" the hash code? Is it necessary and/or preferred?

    Read the article

  • How can I determine if a given git hash exists on a given branch?

    - by pinko
    Background: I use an automated build system which takes a git hash as input, as well as the name of the branch on which that hash exists, and builds it. However, the build system uses the hash alone to check out the code and build it -- it simply stores the branch name, as given, in the build DB metadata. I'm worried about developers accidentally providing the wrong branch name when they kick off a build, causing confusion when people are looking through the build history. So how can I confirm, before passing along the hash and branch name to the build system, that the given hash does in fact come from the given branch?

    Read the article

  • Good PHP / MYSQL hashing solution for large number of text values

    - by Dave
    Short descriptio: Need hashing algorithm solution in php for large number of text values. Long description. PRODUCT_OWNER_TABLE serial_number (auto_inc), product_name, owner_id OWNER_TABLE owner_id (auto_inc), owener_name I need to maintain a database of 200000 unique products and their owners (AND all subsequent changes to ownership). Each product has one owner, but an owner may have MANY different products. Owner names are "Adam Smith", "John Reeves", etc, just text values (quite likely to be unicode as well). I want to optimize the database design, so what i was thinking was, every week when i run this script, it fetchs the owner of a proudct, then checks against a table i suppose similar to PRODUCT_OWNER_TABLE, fetching the owner_id. It then looks up owner_id in OWNER_TABLE. If it matches, then its the same, so it moves on. The problem is when its different... To optimize the database, i think i should be checking against the other "owner_name" entries in OWNER_TABLE to see if that value exists there. If it does, then i should use that owner_id. If it doesnt, then i should add another entry. Note that there is nothing special about the "name". as long as i maintain the correct linkagaes AND make the OWNER_TABLE "read-only, append-new" type table - I should be able create a historical archive of ownership. I need to do this check for 200000 entries, with i dont know how many unique owner names (~50000?). I think i need a hashing solution - the OWNER_TABLE wont be sorted, so search algos wont be optimal. programming language is PHP. database is MYSQL.

    Read the article

  • Collision Attacks, Message Digests and a Possible solution

    - by Dominar
    I've been doing some preliminary research in the area of message digests. Specifically collision attacks of cryptographic hash functions such as MD5 and SHA-1, such as the Postscript example and X.509 certificate duplicate. From what I can tell in the case of the postscript attack, specific data was generated and embedded within the header of the postscript (which is ignored during rendering) which brought about the internal state of the md5 to a state such that the modified wording of the document would lead to a final MD equivalent to the original. The X.509 took a similar approach where by data was injected within the comment/whitespace of the certificate. Ok so here is my question, and I can't seem to find anyone asking this question: Why isn't the length of ONLY the data being consumed added as a final block to the MD calculation? In the case of X.509 - Why is the whitespace and comments being taken into account as part of the MD? Wouldn't a simple processes such as one of the following be enough to resolve the proposed collision attacks: MD(M + |M|) = xyz MD(M + |M| + |M| * magicseed_0 +...+ |M| * magicseed_n) = xyz where : M : is the message |M| : size of the message MD : is the message digest function (eg: md5, sha, whirlpool etc) xyz : is the acutal message digest value for the message M magicseed_{i}: Is a set random values generated with seed based on the internal-state prior to the size being added. This technqiue should work, as to date all such collision attacks rely on adding more data to the original message. In short, the level of difficulty involved in generating a collision message such that: It not only generates the same MD But is also comprehensible/parsible/compliant and is also the same size as the original message, is immensely difficult if not near impossible. Has this approach ever been discussed? Any links to papers etc would be nice.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >