Search Results

Search found 337 results on 14 pages for 'hashing'.

Page 6/14 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How does the hash part in hash maps work?

    - by sub
    So there is this nice picture in the hash maps article on Wikipedia: Everything clear so far, except for the hash function in the middle. How can a function generate the right index from any string? Are the indexes integers in reality too? If yes, how can the function output 1 for John Smith, 2 for Lisa Smith, etc.?

    Read the article

  • Performance of SHA-1 Checksum from Android 2.2 to 2.3 and Higher

    - by sbrichards
    In testing the performance of: package com.srichards.sha; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import com.srichards.sha.R; public class SHAHashActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = new TextView(this); String shaVal = this.getString(R.string.sha); long systimeBefore = System.currentTimeMillis(); String result = shaCheck(shaVal); long systimeResult = System.currentTimeMillis() - systimeBefore; tv.setText("\nRunTime: " + systimeResult + "\nHas been modified? | Hash Value: " + result); setContentView(tv); } public String shaCheck(String shaVal){ try{ String resultant = "null"; MessageDigest digest = MessageDigest.getInstance("SHA1"); ZipFile zf = null; try { zf = new ZipFile("/data/app/com.blah.android-1.apk"); // /data/app/com.blah.android-2.apk } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ZipEntry ze = zf.getEntry("classes.dex"); InputStream file = zf.getInputStream(ze); byte[] dataBytes = new byte[32768]; //65536 32768 int nread = 0; while ((nread = file.read(dataBytes)) != -1) { digest.update(dataBytes, 0, nread); } byte [] rbytes = digest.digest(); StringBuffer sb = new StringBuffer(""); for (int i = 0; i< rbytes.length; i++) { sb.append(Integer.toString((rbytes[i] & 0xff) + 0x100, 16).substring(1)); } if (shaVal.equals(sb.toString())) { resultant = ("\nFalse : " + "\nFound:\n" + sb.toString() + "|" + "\nHave:\n" + shaVal); } else { resultant = ("\nTrue : " + "\nFound:\n" + sb.toString() + "|" + "\nHave:\n" + shaVal); } return resultant; } catch (IOException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; } } On a 2.2 Device I get average runtime of ~350ms, while on newer devices I get runtimes of 26-50ms which is substantially lower. I'm keeping in mind these devices are newer and have better hardware but am also wondering if the platform and the implementation affect performance much and if there is anything that could reduce runtimes on 2.2 devices. Note, the classes.dex of the .apk being accessed is roughly 4MB. Thanks!

    Read the article

  • Perfect hash in Scala.

    - by Lukasz Lew
    I have some class C: class C (...) { ... } I want to use it to index an efficient map. The most efficient map is an Array. So I add a "global" "static" counter in companion object to give each object unique id: object C { var id_counter = 0 } In primary constructor of C, with each creation of C I want to remember global counter value and increase it. Question 1: How to do it? Now I can use id in C objects as perfect hash to index array. But array does not preserve type information like map would, that a given array is indexed by C's id. Question 2: Is it possible to have it with type safety?

    Read the article

  • What is the best way to implement this composite GetHashCode()

    - by Frank Krueger
    I have a simple class: public class TileName { int Zoom, X, Y; public override bool Equals (object obj) { var o = obj as TileName; return (o != null) && (o.Zoom == Zoom) && (o.X == X) && (o.Y == Y); } public override int GetHashCode () { return (Zoom + X + Y).GetHashCode(); } } I was curious if I would get a better distribution of hash codes if I instead did something like: public override int GetHashCode () { return Zoom.GetHashCode() + X.GetHashCode() + Y.GetHashCode(); } This class is going to be used as a Dictionary key, so I do want to make sure there is a decent distribution.

    Read the article

  • unique hash of string

    - by Aly
    Hi, I want to create a unique hash (16 chars long) of an arbitrary length String. Is there a good library that implements MD5 or SHA-1 for C++ with which I can achieve this? (and possibly an example of how to use it)

    Read the article

  • Does the java JFC hash table use seperate chaining resolution? Can I traverse each list in the table

    - by Matt
    I have written a program to store a bunch of strings in a JFC hash table. There are defiantly collisions going on, but I don't really know how it is handling them. My ultimate goal is to print the number of occurrences of each string in the table, and traversing the bucket or list would work nicely. Or maybe counting the collisions? Or do you have another idea of how I could get a count of the elements?

    Read the article

  • Generate a commutative hash based on three sets of numbers?

    - by DarkAmgine
    I need to generate a commutative hash based on three sets of "score" structs. Each score has a "start", an "end" and a "number". Both start and end are usually huge numbers (8-9 digits) but number is just from 1 to 4. I need them to be commutative so the order does not matter. I'm using XOR at the moment but it seems to be giving bad results. Since I'm working with large large datasets, I'd prefer a performance-friendly solution. Any suggestions? Thanks =] public static int getCustomHash(cnvRegion c1, cnvRegion c2, cnvRegion c3) { int part1 = (c1.startLocation * c2.startLocation * c3.startLocation); int part2 = (c1.endLocation * c2.endLocation * c3.endLocation); int part3 = (c1.copyNumber + c2.copyNumber + c3.copyNumber)*23735160; return part1 ^ part2 ^ part3; }

    Read the article

  • What's the state of support for SHA-2 in various platforms?

    - by Cheeso
    I read that SHA-1 is being retired from the FIPS 180-2 standard. Apparently there are weaknesses in SHA-1 that led to this decision. Can anyone elaborate on the basis for that decision? Are there implications for the use of SHA-1 in commercial applications? My real questions are: What is the state of SHA-2 support in various class libraries and platforms? Should I attempt to move to SHA-2? Interested in mainstream platforms: .NET, Java, C/C++, Python, Javascript, etc.

    Read the article

  • Lists Hash function

    - by John Retallack
    I'm trying to make a hash function so I can tell if too lists with same sizes contain the same elements. For exemple this is what I want: f((1 2 3))=f((1 3 2))=f((2 1 3))=f((2 3 1))=f((3 1 2))=f((3 2 1)). Any ideea how can I approch this problem ? I've tried doing the sum of squares of all elements but it turned out that there are collisions,for exemple f((2 2 5))=33=f((1 4 4)) which is wrong as the lists are not the same. I'm looking for a simple approach it there are any.

    Read the article

  • Datastructure choices for highspeed and memory efficient detection of duplicate of strings

    - by Jonathan Holland
    I have a interesting problem that could be solved in a number of ways: I have a function that takes in a string. If this function has never seen this string before, it needs to perform some processing. If the function has seen the string before, it needs to skip processing. After a specified amount of time, the function should accept duplicate strings. This function may be called thousands of time per second, and the string data may be very large. This is a highly abstracted explanation of the real application, just trying to get down to the core concept for the purpose of the question. The function will need to store state in order to detect duplicates. It also will need to store an associated timestamp in order to expire duplicates. It does NOT need to store the strings, a unique hash of the string would be fine, providing there is no false positives due to collisions (Use a perfect hash?), and the hash function was performant enough. The naive implementation would be simply (in C#): Dictionary<String,DateTime> though in the interest of lowering memory footprint and potentially increasing performance I'm evaluating a custom data structures to handle this instead of a basic hashtable. So, given these constraints, what would you use? EDIT, some additional information that might change proposed implementations: 99% of the strings will not be duplicates. Almost all of the duplicates will arrive back to back, or nearly sequentially. In the real world, the function will be called from multiple worker threads, so state management will need to be synchronized.

    Read the article

  • Program to change/obfuscate all hashes (MD5/SHA1) in a directory tree?

    - by anon
    Hi fellas, A) Are there any FOSS programs out there that can manage to hashchange all files in a directory tree? B) Failing that, what methods could be used to develop this capability in a (crappy) self-written program without requiring the program to be sophisticated and content-aware? Is there any (roughly) universally safe location within a file (for example, around EOF?) where on could one simply append/add psuedorandom data so the resulting hash is different? Is there a better/more elegant solution? Muchos gracias

    Read the article

  • Can I use part of MD5 hash for data identification?

    - by sharptooth
    I use MD5 hash for identifying files with unknown origin. No attacker here, so I don't care that MD5 has been broken and one can intendedly generate collisions. My problem is I need to provide logging so that different problems are diagnosed easier. If I log every hash as a hex string that's too long, inconvenient and looks ugly, so I'd like to shorten the hash string. Now I know that just taking a small part of a GUID is a very bad idea - GUIDs are designed to be unique, but part of them are not. Is the same true for MD5 - can I take say first 4 bytes of MD5 and assume that I only get collision probability higher due to the reduced number of bytes compared to the original hash?

    Read the article

  • How to specify hash algorithm when updating LDAP via Java?

    - by JuanZe
    Is there a way to specify the hash algorithm (MD5, SHA1, etc.) to use for storing the passwords when you update an Open LDAP directory using Java APIs with code like this: private void resetPassword(String principal, String newPassword) throws NamingException { InitialDirContext ctxAdmin = null; Hashtable<String, String> ctxData = new Hashtable<String, String>(); ctxData.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); ctxData.put(Context.PROVIDER_URL, "ldap://myserver:389"); ctxData.put(Context.SECURITY_AUTHENTICATION, "simple"); ctxData.put(Context.SECURITY_PRINCIPAL, "admin_dn"); ctxData.put(Context.SECURITY_CREDENTIALS, "admin_passwd"); InitialDirContext ctxAdmin = new InitialDirContext(ctxData); if (newPassword == null || newPassword.equals("")) { String msg = "Password can't be null"; throw new NamingException(msg); } else { if (principal == null || principal.equals("")) { String msg = "Principal can't be null"; throw new NamingException(msg); } else { if (ctxAdmin == null) { String errCtx = "Can't get LDAP context"; throw new NamingException(errCtx); } } } BasicAttribute attr = new BasicAttribute("userpassword", newPassword); ModificationItem modItem = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr); ModificationItem[] items = new ModificationItem[1]; items[0] = modItem; ctxAdmin.modifyAttributes("cn=" + principal + ",ou=Users,dc=com", items); }

    Read the article

  • How do you embed a hash into a file recursively?

    - by oasisbob
    Simplest case: You want to make a text file which says "The MD5 hash of this file is FOOBARHASH". How do you embed the hash, knowing that the embedded hash value and the hash of the file are inter-related? eg, Cisco embeds hash values into their IOS images, which can be verified like this: cisco# verify s72033-advipservicesk9_wan-mz.122-33.SXH7.bin Embedded Hash MD5 : D2BB0668310392BAC803BE5A0BCD0C6A Computed Hash MD5 : D2BB0668310392BAC803BE5A0BCD0C6A IIRC, Ubuntu also includes a txt file in the root of their ISOs which have the hash of the entire ISO. Maybe I'm mistaken, but trying to figure out how to do this blows my mind.

    Read the article

  • Is there a circular hash function?

    - by Phil H
    Thinking about this question on testing string rotation, I wondered: Is there was such thing as a circular/cyclic hash function? E.g. h(abcdef) = h(bcdefa) = h(cdefab) etc Uses for this include scalable algorithms which can check n strings against each other to see where some are rotations of others. I suppose the essence of the hash is to extract information which is order-specific but not position-specific. Maybe something that finds a deterministic 'first position', rotates to it and hashes the result? It all seems plausible, but slightly beyond my grasp at the moment; it must be out there already...

    Read the article

  • What hash algorithms are paralellizable? Optimizing the hashing of large files utilizing on mult-co

    - by DanO
    I'm interested in optimizing the hashing of some large files (optimizing wall clock time). The I/O has been optimized well enough already and the I/O device (local SSD) is only tapped at about 25% of capacity, while one of the CPU cores is completely maxed-out. I have more cores available, and in the future will likely have even more cores. So far I've only been able to tap into more cores if I happen to need multiple hashes of the same file, say an MD5 AND a SHA256 at the same time. I can use the same I/O stream to feed two or more hash algorithms, and I get the faster algorithms done for free (as far as wall clock time). As I understand most hash algorithms, each new bit changes the entire result, and it is inherently challenging/impossible to do in parallel. Are any of the mainstream hash algorithms parallelizable? Are there any non-mainstream hashes that are parallelizable (and that have at least a sample implementation available)? As future CPUs will trend toward more cores and a leveling off in clock speed, is there any way to improve the performance of file hashing? (other than liquid nitrogen cooled overclocking?) or is it inherently non-parallelizable?

    Read the article

  • What hash algorithms are parallelizable? Optimizing the hashing of large files utilizing on multi-co

    - by DanO
    I'm interested in optimizing the hashing of some large files (optimizing wall clock time). The I/O has been optimized well enough already and the I/O device (local SSD) is only tapped at about 25% of capacity, while one of the CPU cores is completely maxed-out. I have more cores available, and in the future will likely have even more cores. So far I've only been able to tap into more cores if I happen to need multiple hashes of the same file, say an MD5 AND a SHA256 at the same time. I can use the same I/O stream to feed two or more hash algorithms, and I get the faster algorithms done for free (as far as wall clock time). As I understand most hash algorithms, each new bit changes the entire result, and it is inherently challenging/impossible to do in parallel. Are any of the mainstream hash algorithms parallelizable? Are there any non-mainstream hashes that are parallelizable (and that have at least a sample implementation available)? As future CPUs will trend toward more cores and a leveling off in clock speed, is there any way to improve the performance of file hashing? (other than liquid nitrogen cooled overclocking?) or is it inherently non-parallelizable?

    Read the article

  • How to change password hashing algorithm when using spring security?

    - by harry
    I'm working on a legacy Spring MVC based web Application which is using a - by current standards - inappropriate hashing algorithm. Now I want to gradually migrate all hashes to bcrypt. My high level strategy is: New hashes are generated with bcrypt by default When a user successfully logs in and has still a legacy hash, the app replaces the old hash with a new bcrypt hash. What is the most idiomatic way of implementing this strategy with Spring Security? Should I use a custom Filter or my on AccessDecisionManager or …?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >