Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has anyone written a stored procedure in the database management tool that can query the decrypted data? #55

Open
Brawns opened this issue Jun 12, 2023 · 4 comments

Comments

@Brawns
Copy link

Brawns commented Jun 12, 2023

No description provided.

@planeteleven0
Copy link

done with clr

@Brawns
Copy link
Author

Brawns commented Jul 8, 2023

Want to directly query the decrypted data in the database management tool

@planeteleven0
Copy link

yes , create a .net framework library project , with same algorithm , use that dll as clr by creating the functions

@cargt3
Copy link

cargt3 commented Nov 20, 2023

my sql script

`SET @keybase = 'xxx';
SET @encrypted_data = 'xxx';

SET @@SESSION.block_encryption_mode = 'aes-256-cbc';

-- Convert the keyBase to binary
SET @keyBaseBinary = CONVERT(@keybase USING utf8);

-- Convert the binary keyBase to Base64
SET @key = TO_BASE64(@keyBaseBinary);

-- Decode the keyBase from Base64 encoding
SET @binary_encrypted_data = FROM_BASE64(@encrypted_data);

-- Extract the first 16 bytes from the decoded data as the IV
SET @Iv = SUBSTRING(@binary_encrypted_data, 1, 16);

-- Remove the IV from the binary data
SET @data_without_iv = SUBSTRING(@binary_encrypted_data, 17);

-- Decrypt the data using AES_DECRYPT in MySQL
SELECT CAST(AES_DECRYPT(@data_without_iv, @key, @Iv) AS CHAR) AS decrypted_data;`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants