HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Advanced Password Trigger

08-18-2003, 07:01 AM#1
XVoltaireX
Ok here is the thing, I am currently creating a Password trigger for my map. The password's characters are undefined, they can in length. Basically the password system is already completed. But I am having problems with the encoding. I want to use the players' name to encode so that a single password only works with a single player. I am trying to change the players names to numbers to encode them then change the back and make sure that it is equal to the players name that entered it. So basically each character is equal to a number. But I hit a roadblock with this idea. And I was wondering if anyone can help me with this encoding system.
08-18-2003, 01:42 PM#2
Aiursrage2k
If you mix up the KEYZ string it might be a little more complex for someone to crack.
Code:
function strlen takes string s returns integer
   local integer i = 0
   if s == "" then
      return i
   endif
   loop     
     exitwhen SubStringBJ(s, i, i) == ""
     set i = i + 1
   endloop
   return i - 1
endfunction

constant function KEYZ takes nothing returns string
   return "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ01234567890"
endfunction

function encode_Key takes string char returns integer
   local string alphaKey = KEYZ()
   local integer max = strlen(alphaKey)
   local integer retval = 0
   local integer i = 0
   loop
     exitwhen i > max
     if SubStringBJ(alphaKey,i,i) == char then
       set retval = i
       set i = max
     endif
     set i = i + 1
   endloop
   return retval
endfunction

function encode_Buff takes string char returns string
   set char = I2S(encode_Key(char))
   if strlen(char) < 2 then
     set char = "0" + char 
   endif
   return char
endfunction

function encode takes string PlayerName returns string
   local integer i = 1
   local integer max = strlen(PlayerName)
   local string tmp = ""
   loop
     exitwhen i > max
     set tmp = tmp + encode_Buff(SubStringBJ(PlayerName,i,i))
     set i = i + 1
   endloop
   return tmp 
endfunction

function decode_Key takes integer i returns string
   return SubStringBJ(KEYZ(),i,i)
endfunction

function decode_Buff takes string char returns string
   return decode_Key(S2I(char))
endfunction

function decode takes string PlayerName returns string
   local integer i = 1
   local integer max = strlen(PlayerName)
   local string tmp = ""
   loop
      exitwhen i > max
      set tmp = tmp + decode_Buff(SubStringBJ(PlayerName,i,i+1))
      set i = i + 2
   endloop
   return tmp 
endfunction
08-18-2003, 05:19 PM#3
Axiverse
local string chrmap = "ABCDEFG...XYZabcde...zy123456780..."

-fore every chr loop and check if substring(chrmap, x, x+1) is equal to the chatacter...

(blizzard uses a similar method to chande ID codes into a string - see cheats.j in war3.mpq)
08-18-2003, 05:45 PM#4
XVoltaireX
ok, thnx I will try that.