# can we encrypt a string (password) using ansible vault.

**URL:** <https://forum.ansible.com/t/can-we-encrypt-a-string-password-using-ansible-vault/28265>\
**Category:** Ansible Project\
**Created:** [August 6, 2018, 4:02am UTC](https://forum.ansible.com/t/can-we-encrypt-a-string-password-using-ansible-vault/28265 "2018-08-06T04:02:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coach.rhca](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@coach.rhca](https://forum.ansible.com/u/coach.rhca)\
**Post date:** [August 6, 2018, 4:02am UTC](https://forum.ansible.com/t/can-we-encrypt-a-string-password-using-ansible-vault/28265/1 "2018-08-06T04:02:01Z")

</div>

Hi,

can we encrypt a string (password) using ansible vault. I have a file which contains the usernames and passwords.

Could we encrypt the username and password inside the file rather then encrypting the file with ansible-vault encrypt. if yes, then how do we go about calling those encrypted users and passwords in the playbook.

Please suggest. Thank you.

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [August 6, 2018, 4:25am UTC](https://forum.ansible.com/t/can-we-encrypt-a-string-password-using-ansible-vault/28265/2 "2018-08-06T04:25:27Z")

</div>

Hi,

Have a look here:  
[https://docs.ansible.com/ansible/latest/user\_guide/vault.html#use-encrypt-string-to-create-encrypted-variables-to-embed-in-yaml](https://docs.ansible.com/ansible/latest/user_guide/vault.html#use-encrypt-string-to-create-encrypted-variables-to-embed-in-yaml)

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![coach.rhca](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@coach.rhca](https://forum.ansible.com/u/coach.rhca)\
**Post date:** [August 6, 2018, 5:20am UTC](https://forum.ansible.com/t/can-we-encrypt-a-string-password-using-ansible-vault/28265/3 "2018-08-06T05:20:35Z")

</div>

Thanks Pshem for sharing … will check the link and get back.

Thank you.
