问题
I have a SQL Server database in Azure that is accessed by a .NET app and by a NodeJS app. I just applied AlwaysEncrypted to a table column that contains sensitive information. I used Azure Key Vault to store the encryption key.
I was wondering if it is possible to display the (decrypted) data in my NodeJS app?
A workaround to this would be to expose the data that I want to query through an API endpoint in my .NET app, and then call that endpoint from my NodeJS app, but I'm looking for a more elegant way of doing it.
回答1:
Based on my understanding, I think the more elegant way you said is that directly using JavaScript to decrypte data for column applied Always Encrypted.
I can't find any code for doing it directly. However, I think there are two ways which you can try.
- According the offical document Using Always Encrypted with the JDBC Driver, you can try to use the node package node-java to bridge an API that using Java to query encrypted column data. Please node the content below.
Always Encrypted is supported only by Microsoft JDBC Driver 6.0 (Preview) or higher for SQL Server with SQL Server 2016 (Preview).
- There is a document Always Encrypted Cryptography describes encryption algorithms and mechanisms to derive cryptographic material used in the Always Encrypted feature in SQL Server and Azure SQL Database. It seems that you can try to decrypt the encrypted data via perform the reverse process of data encryption algorithm with some node packages like crypto-js, bcrypt, etc.
Hope it helps.
来源:https://stackoverflow.com/questions/37066987/display-data-from-an-alwaysencrypted-column-in-a-nodejs-app