0

Below is the data, which is being logged. I need to encrypt string (Numbermr), so that it doesn't show the value in logs as plain txt. Any idea on how to encrypt this string(Numbermr) in java using google cloud KMS?

**     * To log data
     */
    public void logAuditInput(AssignmentInformation assignmentInformation, JSONObject jONObject, String modelHashWithProject, String api_version)
    {

        JSONObject recordsJson = new JSONObject();
        recordsJson.put("uuid", asgnmntInfo.getScoringTicketUUID());
        recordsJson.put("Numbermr", asgnmntInfo.getNumbermr());
        recordsJson.put("timestamp", LocalDateTime.now().toString());
        LOG.debug(recordsJson.toString());
    }
usertj
  • 21
  • 4
  • Have you seen the documentation for encrypting and decrypting? It includes Java examples https://cloud.google.com/kms/docs/encrypt-decrypt. I wonder, though, why log this information at all? Will those values be decrypted somewhere else? If you don't need to decrypt it, but you do need to correlate records with the same Numbermr value, using a secure hash might be a better approach. – Tim Moore Dec 15 '21 at 04:10
  • Not sure if they will decrypt the value somewhere. all i know, is Numbermr might be important, something which we doesn't want to log. – usertj Dec 15 '21 at 18:15
  • Why not leave it out of the log record entirely? – Tim Moore Dec 15 '21 at 20:20
  • encryption is working, but getting an exception while decrypting - "com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Decryption failed: the ciphertext is invalid. Any idea? – usertj Dec 16 '21 at 21:03

0 Answers0