是否可以使用相同的云KMS键在CSV中解密加密的CSV列?

发布于 2025-02-13 16:40:57 字数 897 浏览 0 评论 0原文

我在Cloud KMS中创建一个对称键,然后使用Python加密CSV数据中的某些列(作为字符串,通过解码Ciphertext)。

然后,我将此CSV文件加载到BQ表。我有一个想法可以通过SQL使用KMS解密列,并且我从此 link

但我不确定只有与所提供的数据只有可能SQL函数与否(看起来像是这样),

有些字段我实际上不知道是否要放置一些

DECLARE KMS_RESOURCE_NAME STRING;
SET KMS_RESOURCE_NAME ="gcp-kms://projects/<project>locations/<location/keyRings/<keyring>/cryptoKeys/<key>"
;
select id
, AEAD.DECRYPT_STRING(KEYS.KEYSET_CHAIN(
    KMS_RESOURCE_NAME,
    first_level_keyset,
    name
    additional_authenticated_data)
FROM 
mydataset.mytable

我应该为first_level_keyset附加_authenticaticed_data只需要解密我以前在CSV中所做的预加密列吗?

编辑:

我必须事先加密数据的原因是因为我首先将这些数据存储在GCS中的数据湖中,我希望它加密,并且GCS和BQ中都没有PII数据

I create a symmetric key in Cloud KMS and I used Python to encrypt some of the column in my CSV data (as a string by decoding the ciphertext).

Then, I load this CSV file to a BQ table. I have an idea to decrypt the column using KMS via SQL and I found this document about column-level encryption from this link

But I am not sure that it only possible for the data that encrypted with the provided SQL function or not (seems like it)

There are some field that I don't actually know whether to put something

DECLARE KMS_RESOURCE_NAME STRING;
SET KMS_RESOURCE_NAME ="gcp-kms://projects/<project>locations/<location/keyRings/<keyring>/cryptoKeys/<key>"
;
select id
, AEAD.DECRYPT_STRING(KEYS.KEYSET_CHAIN(
    KMS_RESOURCE_NAME,
    first_level_keyset,
    name
    additional_authenticated_data)
FROM 
mydataset.mytable

What actually I should put for first_level_keyset and additional_authenticated_data if I just need only to decrypt a pre-encrypted column that I did previously in CSV?

Edit:

The reason I have to encrypt data beforehand is because I store these data in my data lake in GCS first which I want it to be encrypted and no PII data in both GCS and BQ

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文