# Redact/reveal

> To try it out today, email us at <support@vgs.io>

## Working with Vault

This page demonstrates how Larky is flexible and shows its benefit of doing many different things within one piece of code which can be placed under one route filter. The code is ready for use together with `curl` examples.

### Larky code sample

There is an example of code below which does different types of body manipulations:

* Redact of `card_number` in two different formats and Persistent storage
* Redact of `cvv` in Volatile storage
* Reveal of `secret` value
* Setting the new values into the new fields
* Removing the old fields from the body

```python
load('@stdlib/json', 'json')
load("@stdlib//builtins", builtins="builtins")
load("@vgs//vault", "vault")

def process(input, ctx):
    body = json.loads(str(input.body))

    # reading data from body
    card = body['card_number']
    cvv = body['cvv']
    alias4 = body['secret']

    # redact operation
    alias1 = vault.redact(card, storage='persistent', format='FPE_SIX_T_FOUR')
    alias2 = vault.redact(card, storage='persistent', format='UUID')
    alias3 = vault.redact(cvv, storage='volatile', format='UUID')

    # reveal operation
    secret = vault.reveal(alias4)

    # setting body
    body['card_6T4'] = alias1
    body['card_generic'] = alias2
    body['cvv_alias'] = alias3
    body['secret'] = secret

    # remove odd values
    body.pop('card_number')
    body.pop('cvv')

    # If you need to remove the alias
    # vault.delete(alias4)

    input.body = builtins.bytes(json.dumps(body))
    return input
```

### Testing

Request to send:

```bash
curl {VAULT_URL}/post \
  -H 'Content-Type: application/json' \
  -d '{
    "card_number": "4532251801577121",
    "cvv": "123",
    "secret": "tok_sandbox_vvLyaGWnxm5msxd8Zh3QS1"
  }'
```

Response example:

```json
{
  "card_6T4": "4532250530167121",
  "card_generic": "tok_sandbox_hUTo6bTm4kRrTKyoNfBCPm",
  "cvv_alias": "tok_sandbox_qjoDDEgRsvSUeGdkDNW6XA",
  "secret": "FNfcatCkg5yqh5mPBEwuxbbVFNfcatCkg5yqh5mPBEwuxbbV"
}
```

### Useful links

* [Supported formats](/vault/tokens.md#alias-formats)
* [YAML file export/import](/vault/developer-tools/vault-management/yaml.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/larky/code-examples/redact-reveal.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
