Functions에서 Cipher 사용은 Operational User License가 필요합니다. 이 작업(해싱, 암호화, 복호화)에 대해 checkpoints가 구성된 경우, 라이선스는 checkpoints 우회를 허용해야 합니다.
Functions Code Repositories는 CipherText 오브젝트 속성과 상호작용할 수 있으며, 대량 암호화 또는 대량 복호화와 같은 정교한 로직을 가능하게 합니다. Functions 시작에 대한 확인은 이 튜토리얼을 참고하세요.
아래 예제에서는 다음 속성을 가진 EncryptedCustomer
오브젝트가 있다고 가정합니다:
name
id
이 오브젝트와 상호작용하기 위해 두 가지 함수를 작성할 것입니다:
decryptEncryptedCustomer()
는 EncryptedCustomer
오브젝트를 받아 평문 이름을 반환합니다.updateEncryptedName()
는 EncryptedCustomer
오브젝트와 newName
을 받아 그 오브젝트의 암호화된 이름을 newName
으로 업데이트합니다.이 예제에서는 EncryptedCustomer
오브젝트의 name
속성을 복호화하고 반환합니다.
Copied!1 2 3 4 5 6 7
import { 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 8
import { 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); }