Spec-Zone.ru › ColdFusion

generateSecretKey

Generates a secure random key value for use in the encrypt and decrypt functions.

generateSecretKey([algorithm] [,keysize]) → returns string

  • CF7+
  • Lucee
  • BL 1.0.0+
  • See Also: encrypt decrypt

    Argument Reference

    algorithm string

    The encryption algorithm used to generate the key. NOTE: You cannot use generateSecretKey() to create a key for the CFMX_COMPAT default algorithm in encrypt() and decrypt() functions.
    Values:
    • AES
    • BLOWFISH
    • DES
    • DESEDE

    keysize numeric
    Default: 128

    Number of bits requested in the key for the specified algorithm (when allowed by JDK).
    Values:
    • 128
    • 192
    • 256
    • 512

    Links more information about generateSecretKey

    • Generating AES 256 bit Key - How to enable unlimited strength crypto in Java.

    Examples
    Sample code invoking the generateSecretKey function

    Generate an AES 128 bit Key

    Generate an AES key and use it to encrypt and decrypt a secret.

    ex={};
    ex.key = generateSecretKey("AES");
    ex.secret = "top secret";
    ex.encrypted=encrypt(ex.secret, ex.key, "AES", "Base64");
    ex.decrypted=decrypt(ex.encrypted, ex.key, "AES", "Base64");
    writeDump(ex);

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/generatesecretkey

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API