This question is almost identical to a previous question (Keyboard Layout library to find Neighboring Keys given an input key). However, that question is 5 years old.
Is there a library I can import that will tell me, for a given key k, which keys neighbor k? I know I can manually create this mapping, but it would be great if something more robust was already out there.
Per Alex's comment, this is for a US English QWERTY keyboard.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am attempting to learn more about password hashing. I am pretty used to java and am trying to write my own hashing function for a password. I understand you should never implement your own password security this is purely an academic endeavor. I have made my own implementation of HashMap and other data structures. I would appreciate a description of how hashing works and code fragments if needed. I have searched for an answer but all I can find is how to use SHA 256 (or others ) to hash a password. I would like to make my own to learn more about the algorithms. Thank you for any and all help.
p.s.
To clarify, I know there are algorithms that you can import in java to hash password. I am looking for a description of how these functions work and how the are similar to a hashMap so I can attempt to replicate it.
This is a very broad question but hopefully a few high level details will help you.
Firstly though, as you said, you should not generally implement a secure hashing function yourself since it is very easy to make mistakes resulting in security vulnerabilities.
Cryptographic hashing, such as is provided in SHA-2 at various bit strengths, is a one way cryptographic process of converting your input bytes into an output of the specified length. Assuming correct algorithms, this output cannot be directly converted back to the input.
For discussions on the SHA-2 algorithm in specific you can start with the wikipedia page: https://en.wikipedia.org/wiki/SHA-2
For designing your own algorithm you would want to take into account the following considerations (as SHA-2 and other hashing algorithms do, excerpted from Wikipedia):
it is deterministic so the same message always results in the same hash
it is quick to compute the hash value for any given message
it is infeasible to generate a message from its hash value except by trying all possible messages
a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value
it is infeasible to find two different messages with the same hash value
Further, for password hashing in particular:
Going against the "quick" consideration above, password hashing algorithms are generally chosen to be slower and more difficult to implement in hardware (e.g. scrypt) in order to reduce the ability to brute force a password when its hash and salt are known. Commonly this is done by doing some 1000+ rounds of SHA-2.
Lastly, outside of the hashing algorithm itself, it is important to make sure the password hashes are salted. Salt here refers to modifying the password (e.g. by prefixing it) before hashing with a randomly generated salt value that is also stored with the hash. This prevents an existing or single dictionary of password hashes from being used against all hashes in your database were it to be compromised (i.e. it forces an attacker to attack each hash individually).
This question already has answers here:
Trie data structures - Java [closed]
(3 answers)
Closed 9 years ago.
I need to create a trie in Java for my Boggle game. I have tried searching for this site for help before hand but only got answers for C or Python but nothing on Java.
Anyways to keep it short, I was wondering how one would go about storing a dictionary (so like a text file of words; around 100k words) into a trie. I've read up about the trie and found it hard to visualize code for it.
Specifically I'm looking for steps to follow when programming (so like what methods I should include and what they do).
Any help would be appreciated!
Have you looked at TrieST? I really suggest you do. Otherwise, I suggest reading this article. Maybe also this one.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
How to make HaspMap if we don’t have any haspmap api?
Just create a class with two properties (key and value) and provide appropriate methods.
If you really need to design it yourself then you should read a book on datastructures and algorithms at least.
Here's a simple c++ vector based HashTable implementation.
I'm taking a punt, and guessing that you mean HashMap, and that the reason you don't have a HashMap API is that you are using Java ME.
The answer is to use HashTable ... which Java ME does have, AFAIK.
On the other hand, if this is a homework question and you have been asked to implement your own hash table from scratch, then you should start by read up on how hash tables work. Refer to your lecture notes, your Data Structures textbook ... or look up "hash table" on Wikipedia / Google
The basis of a hash map is:
1) Having backing storage - an array (or equivalent) that is at least as big as the number of entries you are containing already. Either two arrays one for keys one for values, or an array of tuples of key-value pairs (the latter is probably better)
2) A function that decides which of the key array indices we put new keys into. Usually this will be key.HashCode()%array.Length - but if it is already holding a key and it's not the same key (by key.Equals(), then you try the next bucket to the right, and the next, and so on until we do find one. This is ok to do as long as we do the converse operation when we delete a key from the hash map - in other words, since this 'slide keys over' operation is done because there is no hole, if we make a hole, we must see if a key needs to slide into it to fill the gap (e.g. don't slide any key further left than the first place we would check for it, but otherwise if we can slide left, slide left).
3) Now, to see if a key exists in the HashMap, compute where we would have put it and check that index. If it's occupied and equals(), found it. If it's occupied and doesn't match, check one to the right in the same way. If it's empty, didn't find it.
4) One more operation, a tough one - reconstructing the backing storage with double the size when we're getting close to filling up (the closer to filling up we get, the worse the efficiency is, so you want to double way before you fill up). You have to allocate space for the backing storage twice as big, recompute the position of each key in the old storage for the new one, copy the keys and values over, ditch the old storage and install the new storage.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How are Software License Keys generated?
How do software programs verify the product key offline? Is there already a list of possible keys in the db, or does the program decode the input key in some way? If the latter, how is the decoding done?
Well, there are multitudes of algorithms that can be used to encode/decode product keys (using matricies etc.), but one of the more common methods is by use of a program called Keygen. For more information on Keygen, check out this link.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I need to determine if an unknown 5 or 6 letter string is a valid word, i.e. is in the dictionary. I could submit the string/word to an online dictionary, but I need to check this string/word, which will be different each time, for about 100 to 150 times. This seems to be a bit time consuming.
My next thought would be to try to get a dictionary program of my own. It would need to be in Java as my program is written in Java. Does the Java API already have a class for doing this? Can I get a descent one that someone has already coded, and all I have to do is submit the string/word to it?
My program is not being used for spell checking. I want to write a program for unscrambling the Jumbled Word Puzzles when I get stuck on a scrambled word. Thanks for your suggestions.
You could use one of the open source dictionaries and load it into a database: ftp://ftp.cerias.purdue.edu/pub/dict/ and ftp://ftp.ox.ac.uk/pub/wordlists/
For scrambled words, you might want to look at the Jumble algorithm, an implementation of which is seen here.
If you don't need spell checking this would be really easy. Just load all your words into a HashSet and then check to see if that set contains the word you want to test. There are tons of word lists available.
If you do need a spell checker, then check out aspell or other free APIs.
aspell and its associated word lists and dictionaries might be the answer.
I think aspell has a Java version.
edit: actually it looks like you might do better with this aspell spinoff called Jazzy.
Maybe you can check some wordlist:
http://wordlist.sourceforge.net/
This page has some word lists in text format, so you can process in Java yourself, most easily using a HashSet. You need to use more efficient data structures if efficiency is important.
Maybe you could try Peter Norvig's spelling checker. I think it's an elegant way to get 80-90% accuracy.