# The Usage of Key

After the key and token have been distributed by the key service, the key can be used for encryption and decryption

## Encryption examples (symmetric keys)

```bash
curl  https://100.80.80.91/kmip/2_1   -kv -H"Content-Type:application/json" -XPOST -d '{"tag":   "Encrypt","type":   "Structure","value":[{"tag":   "UniqueIdentifier","type": "TextString","value":   "<Key ID>"},{"tag": "Data",   "type": "ByteString", "value":   "610A"}]}' -H"Authorization:Bearer <YOUR TOKEN>"
Return results：
{"tag":"EncryptResponse","type":"Structure","value":[{"tag":"UniqueIdentifier","type":"TextString","value":"Key ID/Key Alias"},{"tag":"Data","type":"ByteString","value":"6A96"},{"tag":"IvCounterNonce","type":"ByteString","value":"C81CF01F27C72E066234602C"},{"tag":"AuthenticatedEncryptionTag","type":"ByteString","value":"046B8EFA22B32D59DFE25D49E429B549"}]}
```

## Decryption examples (symmetric keys)

```bash
curl  https://100.80.80.91/kmip/2_1   -kv -H"Content-Type:application/json" -XPOST -d '{
  "tag": "Decrypt",
  "type": "Structure",
  "value": [
    {
      "tag":   "UniqueIdentifier",
      "type":   "TextString",
      "value":   "[\"sss\"]"
    },
    {
      "tag": "Data",
      "type":   "ByteString",
      "value": "2C0E"
    },
    {
      "tag":   "IvCounterNonce",
      "type":   "ByteString",
      "value":   "02A3869F93A5D7B90249BAC2"
    },
    {
      "tag":   "AuthenticatedEncryptionTag",
      "type":   "ByteString",
      "value":   "D178F95ED2C67D7195EE584971E6C05E"
    }
  ]
}'
Return results：
{
  "tag":   "DecryptResponse",
  "type": "Structure",
  "value": [
    {
      "tag":   "UniqueIdentifier",
      "type":   "TextString",
      "value":   "da38358e-a298-49ca-b52a-81aa32fcabd5"
    },
    {
      "tag": "Data",
      "type":   "ByteString",
      "value": "610A"
    }
  ]
}
```