2017-10-20 14:59:17 +00:00
|
|
|
|
---
|
2020-01-18 00:18:09 +00:00
|
|
|
|
layout: api
|
|
|
|
|
page_title: /sys/tools - HTTP API
|
|
|
|
|
description: This is the API documentation for a general set of crypto tools.
|
2017-10-20 14:59:17 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# `/sys/tools`
|
|
|
|
|
|
|
|
|
|
The `/sys/tools` endpoints are a general set of tools.
|
|
|
|
|
|
|
|
|
|
## Generate Random Bytes
|
|
|
|
|
|
|
|
|
|
This endpoint returns high-quality random bytes of the specified length.
|
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :--------------------------- |
|
|
|
|
|
| `POST` | `/sys/tools/random(/:bytes)` |
|
2017-10-20 14:59:17 +00:00
|
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
|
|
- `bytes` `(int: 32)` – Specifies the number of bytes to return. This value can
|
|
|
|
|
be specified either in the request body, or as a part of the URL.
|
|
|
|
|
|
|
|
|
|
- `format` `(string: "base64")` – Specifies the output encoding. Valid options
|
|
|
|
|
are `hex` or `base64`.
|
|
|
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"format": "hex"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2017-10-20 14:59:17 +00:00
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
--data @payload.json \
|
2018-03-23 15:41:51 +00:00
|
|
|
|
http://127.0.0.1:8200/v1/sys/tools/random/164
|
2017-10-20 14:59:17 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"random_bytes": "dGhlIHF1aWNrIGJyb3duIGZveAo="
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Hash Data
|
|
|
|
|
|
|
|
|
|
This endpoint returns the cryptographic hash of given data using the specified
|
|
|
|
|
algorithm.
|
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :----------------------------- |
|
|
|
|
|
| `POST` | `/sys/tools/hash(/:algorithm)` |
|
2017-10-20 14:59:17 +00:00
|
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
|
|
- `algorithm` `(string: "sha2-256")` – Specifies the hash algorithm to use. This
|
|
|
|
|
can also be specified as part of the URL. Currently-supported algorithms are:
|
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
- `sha2-224`
|
|
|
|
|
- `sha2-256`
|
|
|
|
|
- `sha2-384`
|
|
|
|
|
- `sha2-512`
|
2021-12-08 18:29:33 +00:00
|
|
|
|
- `sha3-224`
|
|
|
|
|
- `sha3-256`
|
|
|
|
|
- `sha3-384`
|
|
|
|
|
- `sha3-512`
|
2017-10-20 14:59:17 +00:00
|
|
|
|
|
|
|
|
|
- `input` `(string: <required>)` – Specifies the **base64 encoded** input data.
|
|
|
|
|
|
|
|
|
|
- `format` `(string: "hex")` – Specifies the output encoding. This can be either
|
|
|
|
|
`hex` or `base64`.
|
|
|
|
|
|
|
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"input": "adba32=="
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2017-10-20 14:59:17 +00:00
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
--data @payload.json \
|
2018-03-23 15:41:51 +00:00
|
|
|
|
http://127.0.0.1:8200/v1/sys/tools/hash/sha2-512
|
2017-10-20 14:59:17 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"sum": "dGhlIHF1aWNrIGJyb3duIGZveAo="
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|