How is Vault data encrypted and what does the file look like?
AdvancedConceptVault, Privilege Escalation and Error Handling
Answer
The file is a header line plus a hex-encoded payload: $ANSIBLE_VAULT;1.1;AES256 (or 1.2 with a vault ID label). The format uses AES-256 in CTR mode with a key derived from your password using PBKDF2 and a random salt, and the ciphertext is authenticated with an HMAC-SHA256.
Consequences: the same plain text encrypts to different output each time (random salt), so re-encrypting causes noisy Git diffs; the strength depends entirely on the password's strength; and file names and variable structure (for whole-file encryption) are hidden, while inline encrypt_string leaves variable names visible.
More on Vault, Privilege Escalation and Error Handling
What is Ansible Vault?BeginnerWhich `ansible-vault` commands do you use day to day?BeginnerHow do you supply the vault password when running a playbook?BeginnerWhat is `encrypt_string` and when is it better than encrypting a whole file?IntermediateWhat are vault IDs and why use them?AdvancedHow do you rotate a vault password?Intermediate