In this paper, the torsional rigidity of the composite sections formed by different materials is obtained by using a finite element procedure. In the derivation of the differential equation, the Saint-Venant's stress function was used. The obtained partial differential equation was discretized by finite elements to get the potentials in the nodal points. After the calculations of the unknown potentials on the composite cross-section, the torsional rigidity is calculated by integrating the potentials on the solution domain. To test the validity of the proposed algorithm, the available analytical and numerical results from the previous studies were studied. It was seen that this new algorithm is efficient and simpler than the previous ones.