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.)
It's probably a really bad idea to try and roll-your-own here. If you have to ask a question like this, you would probably just be better off using shrink-wrapped solution like SSL rather than trying to make your own protocol. There are a lot of tricky problems around getting these kinds of things right.

However, if you insist on doing this yourself, there are constructions that allow you to do what you want to achieve here.

What you want is a message authentication code (MAC). You can MAC the hash of the variables and then send this across the insecure channel. 

In order to do this safely, you need to use a construction like HMAC. You should particularly use such a construction if you are using SHA-1/SHA-256 as they suffer from message extension attacks.

You also need to guard against replays; that is, where an attacker resends a previously seen message on the channel with the hope of repeating an action or causing some other nefarious effect.

These are just a flavour of the kind of bear-traps that can spring when trying to design your own protocol!