本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
範例組態
我們的用戶端加密程式庫已重新命名為 AWS 資料庫加密 SDK。本開發人員指南仍提供 DynamoDB 加密用戶端的相關資訊。 |
下列範例示範如何設定標準和複合信標。下列組態不提供信標長度。如需決定組態適當信標長度的說明,請參閱選擇信標長度。
若要查看示範如何設定和使用信標的完整程式碼範例,請參閱上的 aws-database-encryption-sdk-dynamodb 儲存庫中的 Java
標準信標
如果您要查詢inspector_id_last4
欄位中的完全相符項目,請使用下列組態建立標準信標。
- Java
-
List<StandardBeacon> standardBeaconList = new ArrayList<>(); StandardBeacon exampleStandardBeacon = StandardBeacon.builder() .name("
inspector_id_last4
") .length(beaconLengthInBits) .build(); standardBeaconList.add(exampleStandardBeacon); - C# / .NET
-
var standardBeaconList = new List<StandardBeacon>>); StandardBeacon exampleStandardBeacon = new StandardBeacon { Name = "
inspector_id_last4
", Length = 10 }; standardBeaconList.Add(exampleStandardBeacon);
複合信標
如果要在inspector_id_last4
和上查詢資UnitInspection
料庫inspector_id_last4.unit
,請使用下列組態建立複合信標。此複合信標僅需要加密的零件。
- Java
-
// 1. Create standard beacons for the inspector_id_last4 and unit fields. List<StandardBeacon> standardBeaconList = new ArrayList<>); StandardBeacon inspectorBeacon = StandardBeacon.builder() .name("
inspector_id_last4
") .length(beaconLengthInBits) .build(); standardBeaconList.add(inspectorBeacon); StandardBeacon unitBeacon = StandardBeacon.builder() .name("unit
") .length(beaconLengthInBits) .build(); standardBeaconList.add(unitBeacon); // 2. Define the encrypted parts. List<EncryptedPart> encryptedPartList = new ArrayList<>); // Each encrypted part needs a name and prefix // The name must be the name of the standard beacon // The prefix must be unique // For this example we use the prefix "I-" for "inspector_id_last4" // and "U-" for "unit" EncryptedPart encryptedPartInspector = EncryptedPart.builder() .name("inspector_id_last4
") .prefix("I-") .build(); encryptedPartList.add(encryptedPartInspector); EncryptedPart encryptedPartUnit = EncryptedPart.builder() .name("unit
") .prefix("U-") .build(); encryptedPartList.add(encryptedPartUnit); // 3. Create the compound beacon. // This compound beacon only requires a name, split character, // and list of encrypted parts CompoundBeacon inspectorUnitBeacon = CompoundBeacon.builder() .name("inspectorUnitBeacon
") .split(".") .sensitive(encryptedPartList) .build(); - C# / .NET
-
// 1. Create standard beacons for the inspector_id_last4 and unit fields. StandardBeacon inspectorBeacon = new StandardBeacon { Name = "
inspector_id_last4
", Length = 10 }; standardBeaconList.Add(inspectorBeacon); StandardBeacon unitBeacon = new StandardBeacon { Name = "unit
", Length = 30 }; standardBeaconList.Add(unitBeacon); // 2. Define the encrypted parts. var last4EncryptedPart = new EncryptedPart // Each encrypted part needs a name and prefix // The name must be the name of the standard beacon // The prefix must be unique // For this example we use the prefix "I-" for "inspector_id_last4" // and "U-" for "unit" var last4EncryptedPart = new EncryptedPart { Name = "inspector_id_last4
", Prefix = "I-" }; encryptedPartList.Add(last4EncryptedPart); var unitEncryptedPart = new EncryptedPart { Name = "unit
", Prefix = "U-" }; encryptedPartList.Add(unitEncryptedPart); // 3. Create the compound beacon. // This compound beacon only requires a name, split character, // and list of encrypted parts var compoundBeaconList = new List<CompoundBeacon>>); var inspectorCompoundBeacon = new CompoundBeacon { Name = "inspector_id_last4
", Split = ".", Encrypted = encryptedPartList }; compoundBeaconList.Add(inspectorCompoundBeacon);
設定信標
使用信標