PHP code example of titoshadow / ansible-vault

1. Go to this page and download the library: Download titoshadow/ansible-vault library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

titoshadow / ansible-vault example snippets


use Titoshadow\AnsibleVault\AnsibleVault;

...

// Create an instance of the library
$vault = new AnsibleVault('/path/to/vault-password-file');
 
$encryptedString = $vault->encryptString('Sensitive data');
 
$decryptedString = $vault->decryptString($encryptedString);
 
$vault->encrypt('/path/to/plain-text-file');
 
$vault->decrypt('/path/to/encrypted-file');
 
$vault->create('/path/to/new-vault-file', 'Content of the vault');
 
$vault->edit('/path/to/vault-file');
 
$vault->rekey('/path/to/vault-file', 'old-password', 'new-password');
 
$vault->remove('/path/to/vault-file');