1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date, ,> -- Description: BASE64 디코딩 함수 -- ============================================= Create FUNCTION [dbo].[Base64Decode] ( @Encoded VARCHAR(max) ) RETURNS VARCHAR(MAX) BEGIN declare @Decoded VARCHAR(max) SELECT @Decoded = CAST(CAST(N'' AS XML).value('xs:base64Binary(sql:column("bin"))', 'VARBINARY(MAX)') AS VARCHAR(MAX)) FROM ( SELECT CAST(@Encoded AS VARCHAR(MAX)) AS bin ) AS bin_sql_server_temp; RETURN @Decoded END |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date, ,> -- Description: BASE64 인코딩 함수 -- ============================================= Create FUNCTION [dbo].[Base64Encode] ( @plain VARCHAR(max) ) RETURNS VARCHAR(MAX) BEGIN declare @encoded VARCHAR(max) SELECT @encoded = CAST(N'' AS XML).value('xs:base64Binary(xs:hexBinary(sql:column("bin")))', 'VARCHAR(MAX)') FROM ( SELECT CAST(@plain AS VARBINARY(MAX)) AS bin ) AS bin_sql_server_temp; RETURN @encoded END |
사용
1 2 3 4 5 6 7 8 9 10 11 |
Select dbo.Base64Encode('123232') as number //결과 MTIzMjMy Select dbo.Base64Decode('MTIzMjMy') as number //결과 123232 |