Skip to content

Instantly share code, notes, and snippets.

@ststeiger
Created August 18, 2023 14:41
Show Gist options
  • Save ststeiger/e25b1bad2fc95ae7c190a539ba227a41 to your computer and use it in GitHub Desktop.
Save ststeiger/e25b1bad2fc95ae7c190a539ba227a41 to your computer and use it in GitHub Desktop.
Crypt vs. Plain - text length comparison
-- SELECT dbo.AesEncrypt(''), dbo.AesDecrypt('615ca4a4b3e23e5b500ff7352a519e39')
-- SELECT dbo.DesEncrypt('test'), dbo.DesDecrypt('WNSw7KxMxW4=')
;WITH CTE_PlainText AS
(
SELECT i, REPLICATE('A', i) AS plainText FROM tfu_RPT_All_Interval(0, 99,1)
)
,CTE AS
(
SELECT
CTE_PlainText.*
,dbo.DesEncrypt(plainText) AS cipherText
FROM CTE_PlainText
)
,LOL AS (
SELECT
CTE.*
,LEN(CTE.plainText) AS plainLength
,LEN(CTE.cipherText) AS cipherLength
,LEN(CTE.plainText)/8 +1 as block
FROM CTE
)
SELECT
block
,MIN(plainLength) AS plainLength_MIN
,MAX(plainLength) AS plainLength_MAX
,MIN(cipherLength) AS cipherLength
FROM LoL
GROUP BY block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment