Whatever message this page gives is out now! Go check it out!

GenerateBCryptHash

Last update:
May 18, 2026

Description

It is a password-hashing cryptographic function that takes an input and hashes it into a fixed size output.

Syntax

GenerateBCryptHash(plaintext, options)

History

ColdFusion (2021 release): Added this function.

Parameters

Parameter
Description
plaintext
(Required) The input string on which the hash function must be run.
options
(Optional) A struct with the following values:
  • version- Version of the BCrypt hash to generate ("$2a","$2y" or "$2b"). Default is "$2a".
  • rounds - Number of rounds to run the hash functions. Default is 10.

Example

<cfscript> 
    stringToEncrypt = "Sample string" 
    options = StructNew() 
    options.rounds = 4 
    options.version = "$2a" 
    bcrypted = GenerateBCryptHash(stringToEncrypt, options) 
    writeDump(bcrypted) 
</cfscript>

Output

$2a$04$3rPqpEgx3CIZEVybl3myYu/IxZMttS5.DAX/WMZN8LYTCtU0oJY9G

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page