As the title states, say you create a hypothetical completely random string like one used for a OTP. Would hashing the string (provided it is the same length and possible characters as the hash output) and using the hash make the OTP any less cryptographically secure then just using the string as a key?


Hashing never outputs random string.

A hash algorithm is an algorithm which manipulates the input data in very strictly defined steps and outputs the result.

You can't know how the output will looks like before calculating the hash, so according to your question: if you input a random data, the output will look like random (but only to you, and not to the original data).

As much the length of input matches length of hash output, both methods are safe enough.


In practice your randomness is not degraded.

(For input size == output size: Any reduction in entropy would be through unnecessary collisions. They exist, but are rare enough that you can publish a paper about it when you find one. So it will not happen often enough to affect you.)

Mot likely it will improve the security of your cipher.

(In the case that your random string is not completely random, and it´s possible to use previous outputs of your random generator to predict future outputs, hashing will save you. An attacker will most likely not be able to make any predictions from hash(randomstring1) ).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.