# Utilities

Directus comes with various utility endpoints you can use to simplify your development flow.


# Create a Hash

Create a hash for a given string.

# Parameters

# project required

The project you're targetting.

# Attributes

# string required

String you want to hash.

# Query

No query parameters available.

# Returns

Returns the hash for the string.

Endpoint
  POST /:project/utils/hash
Request
{
  "string": "Directus"
}
Response
{
  "data": {
    "hash": "$2y$10$yBKRgLWmGnrPxi4WXec/0eVkoJNZoNGufbmD38qSZMZnVtq47.tBi"
  }
}

# Verify a Hashed String

Check if a hash is valid for a given string.

# Parameters

# project required

The project you're targetting.

# Attributes

# string required

String you want to hash.

# hash required

The hash you want to verify.

# Query

No query parameters available.

# Returns

Returns a boolean called valid.

Endpoint
  POST /:project/utils/hash/match
Request
{
  "hash": "$2y$10$yBKRgLWmGnrPxi4WXec/0eVkoJNZoNGufbmD38qSZMZnVtq47.tBi",
  "string": "Directus"
}
Response
{
  "data": {
    "valid": true
  }
}

# Generate a Random String

Returns a random string of given length.

# Parameters

# project required

The project you're targetting.

# Attributes

# length optional

How long the string should be. Defaults to 32.

# Query

No query parameters available.

# Returns

Returns a boolean called valid.

Endpoint
  POST /:project/utils/random/string
Request
{
  "length": 10
}
Response
{
  "data": {
    "random": "1>M3+4oh.S"
  }
}

# Generate a 2FA Secret

Returns a random string that can be used as a 2FA secret

# Parameters

# project required

The project you're targetting.

# Query

No query parameters available.

# Returns

Returns a boolean called valid.

Endpoint
   GET /:project/utils/2fa_secret
Response
{
  "data": {
    "2fa_secret": "NWLNVDRK7VKMG3VY"
  }
}