set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION [dbo].[myencrypt](@phrase VARCHAR(100),
@action VARCHAR(1))
RETURNs varchar(200) aS
begin
declare
@longitud int,
@i int,
@phrase_dkrpt VARCHAR(200),
@phrase_dkrpt_temp VARCHAR(200)
set @i = 1
set @longitud = 0
set @phrase_dkrpt = ''
set @phrase_dkrpt_temp = ''
select @longitud = len(@phrase)
while @i <= @longitud
begin
IF (@action = 'E')
begin
SELECT @phrase_dkrpt_temp = char(Ascii(SUBSTRing(@phrase,@i,1))+64)
end
else
begin
if (@action = 'D')
begin
SELECT @phrase_dkrpt_temp = char(Ascii(SUBSTRing(@phrase,@i,1))-64)
end
end
select @phrase_dkrpt = @phrase_dkrpt + @phrase_dkrpt_temp
set @i = @i + 1
---select @phrase_dkrpt = @phrase_dkrpt + cast(@i as varchar)
end
RETURN @phrase_dkrpt
end
No hay comentarios:
Publicar un comentario