The mass does depend on the state: it's a basic point of string theory that it gives a deeper derivation of properties of particles such as their masses and charges: they're derived from a deeper starting point. The mass of a particle is no longer a constant: it is an eigenvalue of an operator acting on the string. The set (spectrum) of possible masses of particles - that are fundamentally strings in a state - is calculated in an analogy with the spectrum of the Hydrogen atom or any other bound state in quantum mechanics.
Classically, the mass of a string would only be given by the tension times the length of the string (which is dynamical). Quantum mechanically, the mass also has contributions from the kinetic energy, because of the $E=mc^2$ equivalence between the mass and energy.
The squared mass operator for an open string is given by
$$ m^2 = 2\pi T \sum_{n=1}^\infty \sum_{i=1}^{D-2} \alpha_{-n}^i \alpha_n^i $$
Here, $T$ is the tension of the string. The constant $2\pi T$ is usually written as $1/ \alpha'$ (read: "one over alpha prime") where $\alpha'$ is called the Regge slope.
The term $\alpha_{-n}^i \alpha_n^i$ is equal to $n$ times the integer-valued excitation level of the quantum harmonic oscillator associated with the $n$-th Fourier mode (standing wave) of the coordinate $X^i$ along the open string. As you can see, the squared mass is $2\pi T$ times an integer. That's the spectrum of open (bosonic) strings in the flat space.
For closed strings, the formula for $m^2$ has different factors of $2$ and contains sums over left-moving and right-moving oscillators. For superstrings, there are fermions and the integer may also be half-integer, with additional interesting technicalities.
See also:
What is tension in string theory?