# How hard/easy will be to break a SHA-1 or SHA-256 hash if the attacker knows part of the original text?

I'm creating an algorithm to hash some text variables (20/30 characters long) to send them across an insecure channel. I'm not dealing with high security data, so no credits card numbers or any other very sensitive information.

The original text variable is composed like this:

{secret-client-code,public-random-code}


Then that is hashed and sent across the channel. However, the public random code is sent raw in the channel, so an attacker will know it. Does this make my hashing vulnerable to an attacker considering that the random code is about 30% of the whole variable? (I can change this if needed.)

• What is your objective? Your objective is likely not creating an algorithm to hash some text variables, since that objective is directly met by applying SHA-1 or SHA-256. If your objective is limited to send text over an insecure channel, there's nothing to prevent you from doing that. We are left guessing that your objective likely is ensuring the origin, or/and protecting the integrity, or/and the confidentiality, of some of the text sent, by mean of hashing. Also we do not know what we can assume the sender and receiver initially have as key material. – fgrieu Oct 6 '13 at 10:05
• It depends on how long and random the secret and public data are. Looks like password hashing to me and if the channel is insecure you might want to consider other options. I agree with fgrieu's comment. – rath Oct 6 '13 at 23:21