Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
---
|
2020-03-18 18:46:47 -04:00
|
|
|
page_title: bcrypt - Functions - Configuration Language
|
2020-04-02 19:39:47 -04:00
|
|
|
sidebar_title: bcrypt
|
Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
description: |-
|
|
|
|
The bcrypt function computes a hash of the given string using the Blowfish
|
|
|
|
cipher.
|
|
|
|
---
|
|
|
|
|
|
|
|
# `bcrypt` Function
|
|
|
|
|
|
|
|
`bcrypt` computes a hash of the given string using the Blowfish cipher,
|
|
|
|
returning a string in [the _Modular Crypt
|
|
|
|
Format_](https://passlib.readthedocs.io/en/stable/modular_crypt_format.html)
|
|
|
|
usually expected in the shadow password file on many Unix systems.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
bcrypt(string, cost)
|
|
|
|
```
|
|
|
|
|
|
|
|
The `cost` argument is optional and will default to 10 if unspecified.
|
|
|
|
|
|
|
|
Since a bcrypt hash value includes a randomly selected salt, each call to this
|
|
|
|
function will return a different value, even if the given string and cost are
|
|
|
|
the same. Using this function directly with resource arguments will therefore
|
|
|
|
cause spurious diffs. We recommend using this function only in `provisioner` or
|
|
|
|
`post-processor` blocks, or in data resources whose results are only used in
|
|
|
|
those blocks.
|
|
|
|
|
|
|
|
The version prefix on the generated string (e.g. `$2a$`) may change in future
|
|
|
|
versions of Packer.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2020-05-29 17:12:05 -04:00
|
|
|
```shell-session
|
Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
> bcrypt("hello world")
|
|
|
|
$2a$10$D5grTTzcsqyvAeIAnY/mYOIqliCoG7eAMX0/oFcuD.iErkksEbcAa
|
|
|
|
```
|