sql server - Reverse a password string and then for each character reversed display the previous letter in the alphabet -
we have application stores passwords in following order in database; reverse original password user creates , increments characters 1. instance if choose password - 'demo' - password stored - 'pnfe' - used reverse(column) , reverses column instead of demo being stored pfne stored enfp can see enfp demo incremented 1 character.
i started working @ company , no means programmer, looking around database tables , accidentally stumbled upon table. reason want able see password when running script or query because people here forget passwords every other week, either have reset passwords or try work out, schlepp. appreciated.
cheers jason
msdn has example of this. modified take previous ascii value ever db has, in reverse, , return it.
if object_id('tempdb..#psswd') not null drop table #psswd create table #psswd (userid int, pswd varchar(40)) insert #psswd (userid, pswd) values (1,'pnfe'), (2,'tofuujl') declare @userid int = 2 -- create variables character string , current -- position in string. declare @position int -- initialize current position , string variables. set @position = 1; while @position <= datalength((select pswd #psswd userid = @userid)) begin select char(ascii(substring(reverse(pswd), @position, 1)) - 1) #psswd userid = @userid set @position = @position + 1 end; go
Comments
Post a Comment