GeneratePBKDFKey

ColdFusion 11 にGeneratePBKDFKey が追加されました。この関数を使用して、ユーザーは PBKDF 2 キーの派生をサポートできます。

戻り値

暗号化キーを含む文字列

履歴

ColdFusion 11:この関数が追加されました。

カテゴリ

セキュリティ関数文字列関数

関数のシンタックス

GeneratePBKDFKey(String algorithm, String string, String salt, int iterations, int keysize )

パラメーター

パラメータ

説明

algorithm

キーを生成する暗号化アルゴリズムです。

以下のアルゴリズムは、スタンダード版およびエンタープライズ版の両方で使用できます。

  • PBKDF2WithHmacSHA1
  • PBKDF2WithHmacSHA224
  • PBKDF2WithHmacSHA256
  • PBKDF2WithHmacSHA384
  • PBKDF2WithHmacSHA512

以下のアルゴリズムは、エンタープライズ版のみで使用できます。

  • PBKDF2WithSHA1
  • PBKDF2WithSHA224
  • PBKDF2WithSHA256
  • PBKDF2WithSHA384
  • PBKDF2WithSHA512
  • PBKDF2WithSHA512-224
  • PBKDF2WithSHA512-256

ColdFusion エンタープライズ版では、 JSAFE がデフォルトの暗号化プロバイダーとして登録されています。 JSAFE は、追加のアルゴリズムを提供します。

string

変換に使用する文字列です。

salt

ランダムなソルトです。標準では、少なくとも 64 ビット(8 文字)のソルト長を推奨しています。ソルトは、SHA1PRNG などの擬似乱数生成器を使用して生成する必要があります。

iterations

PBKDEF の反復処理の実行回数です。反復処理の推奨値は 1000 以上です。

keysize

キーサイズです( 単位: ビット)。

PBKDF2 を使用した暗号化

<cfscript>
       salt="A41n9t0Q";
       password = "Password@123";
       PBKDFalgorithm = "PBKDF2WithSHA512-224";
       dataToEncrypt= "Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
       sed do eiusmod tempor incididunt ut labore et dolore magna aliqua";
       encryptionAlgorithm = "AES";
       derivedKey = GeneratePBKDFKey(PBKDFalgorithm ,password ,salt,4096,128);
       writeOutput("Generated PBKDFKey (Base 64) : " & derivedKey);
       encryptedData = encrypt(dataToEncrypt, derivedKey, encryptionAlgorithm, "BASE64");
       writeoutput("Data After Encryption using PBKDF2: " & encryptedData); 
</cfscript>

PBKDF2 を使用した復号化

<cfscript>
       salt="A41n9t0Q";
       password = "Password@123";
       PBKDFalgorithm = "PBKDF2WithSHA512-224";
       derivedKey = GeneratePBKDFKey(PBKDFalgorithm ,password ,salt,4096,128);
       decryptedData = decrypt(encryptedData, derivedKey, encryptionAlgorithm, "BASE64");
       writeoutput("Data After Decryption using PBKDF2: " & decryptedData); 
</cfscript>
アドビのロゴ

アカウントにログイン