How to insert Identity Server 4 persisted ApiSecret values using T-SQL
You were on the right track to use HASHBYTES
, just need to get the Base64
hash out of the BinaryHash
:
DECLARE @HASHBYTES VARBINARY(128) = hashbytes('sha2_256', 'secret')
SELECT cast(N'' as xml).value('xs:base64Binary(sql:variable("@HASHBYTES"))', 'varchar(128)');