注: 以下の翻訳の正確性は検証されていません。AIPを利用して英語版の原文から機械的に翻訳されたものです。
Functions で Cipher を使用するには、Operational User License が必要です。この操作(ハッシュ化、暗号化、復号)に対して Checkpoint が設定されている場合、ライセンスで Checkpoint のバイパスが許可されている必要があります。
Functions のコードリポジトリを使用すると、CipherText オブジェクトプロパティを操作でき、一括暗号化や一括復号などの高度なロジックを実現できます。Functions をはじめるには、このチュートリアルを参照してください。
以下の例では、次のプロパティを持つ EncryptedCustomer オブジェクトがあるものとします。
nameidこのオブジェクトを操作する2つの関数を作成します。
decryptEncryptedCustomer() は、EncryptedCustomer オブジェクトを受け取り、平文の名前を返します。updateEncryptedName() は、EncryptedCustomer オブジェクトと newName を受け取り、そのオブジェクトの暗号化された名前を newName に更新します。
この例では、EncryptedCustomer オブジェクトの name プロパティを復号して返します。
Copied!1 2 3 4 5 6 7import { Function, Integer, OntologyEditFunction, Edits } from "@foundry/functions-api"; import { Objects, EncryptedCustomers } from "@foundry/ontology-api"; @Function() public async decryptEncryptedCustomer(customer: EncryptedCustomers): Promise<string | undefined> { return await customer.name?.decryptAsync(); }
以下の例では、EncryptedCustomer オブジェクトの name プロパティを更新します。オブジェクトを更新するほかの関数と同様に、この関数には @OntologyEditFunction() と @Edits(EncryptedCustomers) のアノテーションを付ける必要があります。この関数をプレビューで実行しても、オブジェクトは実際には編集されません。
Copied!1 2 3 4 5 6 7 8import { Function, Integer, OntologyEditFunction, Edits } from "@foundry/functions-api"; import { Objects, EncryptedCustomers } from "@foundry/ontology-api"; @OntologyEditFunction() @Edits(EncryptedCustomers) public async updateEncryptedName(customer: EncryptedCustomers, newName: string): Promise<void> { await customer.name?.updateAsync(newName); }