My goal is to build a neural net that can find patterns between a hash and a word on it's own. So that it returns the word of any hash that I will input.

Unfortunatally my skill in the area of neural net isn´t advanced, and I want to use this project to learn more. So I use a German dictionary and encode it via one_hot encoding. Then I generate the sha256 value of every word inside (before I have done this I cleaned the file and wrote every word in another line) it. So I got an big array with the shape of 20000x20000 for the words and another for the hashs.

So then I used the a example of the Keras homepage for binary classification because the one_hot values are represented by ones and zeros.

So if I want to predict a hashs I get these error: Error when checking : expected dense_1_input to have shape (20000,) but got array with shape (1,). So I don't know if this model is working for my problem but I couldn't convert one hash into a size of 20000x20000. (The hash will one_hot encoded for that prediction). So how could I get it to accept different shaped hashs/one hash only?

Is there a way to train the model with each hash after another for example with a for loop?!
EDIT: So I figured out that I can convert a list of characters into a numpy.array with 2 dimensions. So I hot_encoded every character and create a list of them, these list I passed inside the np.array(words,ndim=2). So this I have done for my hashs aswell. Then after I run the code I got this error: ValueError: setting an array element with a sequence So I tried to reshape the array with the .reshape(20000) command but nothing chaged. So what to do with that? EDIT2: I figured out now that the problem is that enhot_encoding generates diffrent sized "arrays" for each word, and if I fill this into a real array and this into a neuronal net it have to return this error. But still the question is: How to convert single words and hashs to a format that I can train a neuronal net with and get usefull output so I can enter any hash and it should return some kind of word(lable). If you need the actual code please inform me and I will upload it`s current state. Code:

model = Sequential()
model.add(Dense(64, input_shape=20000, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(units=64, activation="relu"))
model.add(Dense(19957, activation='sigmoid'))
model.compile(loss='binary_crossentropy',optimizer='rmsprop', metrics=['accuracy'])
print("Fitting data...")
model.fit(test_hashs,test_words ,epochs=10,batch_size=128, verbose=1)

train_y=input("Input a hash that is not contained in the training data: ")
#score=model.evaluate(test_x, test_y, batch_size=128,)
print("Score: "+score)
for i in prediction:

1 Answer 1


I'm not quite sure it's possible. Hash functions are used to map an input to an output in a way that is not reversible.

Many companies store a hash of your password on their servers so in case of a security breach they haven't given the adversaries a long list of passwords.

As far as it goes for finding the exact hash of a word, it seems infeasible.

Edit: Binary classification refers to the possible output being two possible states. A ten dimensional one-hot vector is not binary.

  • $\begingroup$ I figured out that it isn't binary classification and I try currently to understand NN but I will not warm up with the predictions... $\endgroup$
    – Flajt
    Commented Apr 9, 2018 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .