It is stated in Misbahush-Shari`ah that Imam as-Sadiq (AS) said: " The meaning of the salam at the end of each salat is 'security', that is, whoever obeys the command of Allah and the tradition of His Prophet (SA), with a submissive heart, will be secured from the trials of this world and exempted from the tortures of the Hereafter. `Salam' is one of the names of Allah, the Exalted. He trusted it to His creatures so that they may use its concept in their transactions, trusts and annexations, evidencing reciprocal companionship among themselves and the correctness of their association . If you wish to use the salam in its proper place and according to its meaning, you must fear Allah, and your religion, heart and mind should be secured on your part. So, do not make them filthy by the darkness of sinning, and do not cause your protectors (angels) to be vexed, tired and disgusted with your maltreating them. Both your friend and, your enemy should be secured from you, as the one whose close friends are not secured from him, the strangers are certainly more expected not to be so. And whoever does not put the salam in those proper places, his will be no salam and no taslim, and his salam will be a false one, even if he shows it off before the people. 
Being secured from the trials of this world means to be secured from Satanic intrusions, because obeying the commands of Allah secures one against the intrusion of Satan: "Surely prayer forbids indecency and dishonour." 
Then, he refers to one of the secrets of the "salam" and says: "salam" is one of the Names of Allah. He trusted it to His creatures. "This is a hint at the appearance of beings from the Divine Names. The salik servant should declare this divine grace, which has been trusted in the inside of his essence and nature, and use it in all of his dealings, associations, trusts and relationships, and spread it throughout his inside and outside domains. He should use it in his dealings with Allah and His religion so as not to betray the divine trust. Thus, he is to spread the truth of "salam" in all his worldly and heavenly powers as well as in his customs, beliefs, morals and actions, so that he may be secured from all intrusions.
The way to this security is, thus, said to be taqwa. It should be realized that taqwa is of many degrees and stages:
The external taqwa: It means protecting the outside against the pollution and the darkness of formal sinning. This is the taqwa of the common people.
The internal taqwa: This means protecting the inside and purifying it from extravagance and shortcoming and exceeding the limit of moderateness in morality and spiritual instincts. This is the taqwa of the elite.
The taqwa of the mind: It is protecting and purifying the mind from being spent on the non-divine sciences. The divine sciences are those which deal with the divine laws and religion. Other natural sciences and the like which are required for knowing the manifestations of Allah, are also divine. But if they are not for that, they are not divine, even if they are discussions about the Beginning and the Resurrection. This is the taqwa of "the choice of the elite" [akhass-i khawass].
The taqwa of the heart: It is protecting the heart against seeing or discussing other than Allah. This is the taqwa of the walis [auliya']. The noble hadith in which Allah, the Exalted, says: "I am the co-sitter to the one who sits with Me,"  refers to this hearty privacy, which is the best privacy, and the other ones are preliminaries to this one.
So, the one who acquires all these degrees of taqwa, his religion, intellect, spirit, heart and all his internal and external powers will remain sound and safe, and the angels in charge of protecting him will not be vexed, tired or disgusted with him. The dealings and the company of such a person with both the friend and the enemy, will be done in peace, or, actually, enmity will be uprooted from his heart, no matter how much his enemies are hostile to him. But the one who has not acquired all the degrees of taqwa, would proportionally be deprived from the emanation of salam, and would be nearer to the horizon of hypocrisy, from which we take refuge with Allah. With peace! [was-salam].
. Misbahush-Shari'ah, ch. 18, "On Salam". Biharul Anwar, vol. 82, p. 307.
. Surah al-Ankabut : 45.
. Al-Mawahibus-Saniyah, p. 77. Al-Mahajjatul Bayda', vol. 8, p. 58 (with a slight difference).