Skip to content

Commit

Permalink
Fix explicit decryption code in tour
Browse files Browse the repository at this point in the history
  • Loading branch information
jyemin committed Nov 15, 2022
1 parent d68e311 commit a320da5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public static void main(final String[] args) {
System.out.println(doc.toJson());

// Explicitly decrypt the field
System.out.println(clientEncryption.decrypt(new BsonBinary(doc.get("encryptedField", Binary.class).getData())));
Binary encryptedField = doc.get("encryptedField", Binary.class);
BsonString decryptedField = clientEncryption.decrypt(new BsonBinary(encryptedField.getType(), encryptedField.getData())).asString();
System.out.println(decryptedField.getValue());

// release resources
clientEncryption.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public static void main(final String[] args) {
System.out.println(doc.toJson());

// Explicitly decrypt the field
System.out.println(clientEncryption.decrypt(new BsonBinary(doc.get("encryptedField", Binary.class).getData())));
Binary encryptedField = doc.get("encryptedField", Binary.class);
BsonString decryptedField = clientEncryption.decrypt(new BsonBinary(encryptedField.getType(), encryptedField.getData())).asString();
System.out.println(decryptedField.getValue());

// release resources
clientEncryption.close();
Expand Down

0 comments on commit a320da5

Please sign in to comment.