aka Blue Posted September 20, 2016 Share Posted September 20, 2016 Buenos días/tardes/noches. Estoy creando un pequeño sistema de cifrado de contraseñas, debido a que los que hay actualmente disponibles (MD5, SHA1) son más que fáciles de descifrar por personas ajenas a un proyecto. Por ahora tengo algo así creado, me gustaría saber cómo podría hacer la sustitución de strings y lectura normal ya que ando aprendiendo con las funciones de string. Gracias de antemano local letras = { {"a", ""}, {"b", ""}, {"c", ""}, {"d", ""}, {"e", ""}, {"f", ""}, {"g", ""}, {"h", ""}, {"i", ""}, {"j", ""}, {"k", ""}, {"l", ""}, {"m", ""}, {"n", ""}, {"ñ", ""}, {"o", ""}, {"p", ""}, {"q", ""}, {"r", ""}, {"s", ""}, {"t", ""}, {"u", ""}, {"v", ""}, {"w", ""}, {"x", ""}, {"y", ""}, {"z", ""}, {"A", ""}, {"B", ""}, {"C", ""}, {"D", ""}, {"E", ""}, {"F", ""}, {"G", ""}, {"H", ""}, {"I", ""}, {"J", ""}, {"K", ""}, {"L", ""}, {"M", ""}, {"N", ""}, {"Ñ", ""}, {"O", ""}, {"P", ""}, {"Q", ""}, {"R", ""}, {"S", ""}, {"T", ""}, {"U", ""}, {"V", ""}, {"W", ""}, {"X", ""}, {"Y", ""}, {"Z", ""}, {"0", ""}, {"1", ""}, {"2", ""}, {"3", ""}, {"4", ""}, {"5", ""}, {"6", ""}, {"7", ""}, {"8", ""}, {"9", ""}, {"(", ""}, {")", ""}, {"{", ""}, {"}", ""}, {"[", ""}, {"]", ""}, {'"', ""}, {"'", ""}, {"?", ""}, {"¿", ""}, {"!", ""}, {"¡", ""}, {"+", ""}, {"-", ""}, {"\t", ""}, {"\n", ""}, {",", ""}, {"=", ""} } Link to comment
Simple0x47 Posted September 20, 2016 Share Posted September 20, 2016 Aqui tienes un pequeño ejemplo. local keys = { { "a", "$" }, { "b", "·" }, { "c", "!" } } local _string = "abc" for i = 1, #keys do local _t = keys[ i ] _string = string.gsub( _string, _t[ 1 ], _t[ 2 ] ) end Link to comment
-Rex- Posted September 20, 2016 Share Posted September 20, 2016 1 hour ago, Simple01 said: Aqui tienes un pequeño ejemplo. local keys = { { "a", "$" }, { "b", "·" }, { "c", "!" } } local _string = "abc" for i = 1, #keys do local _t = keys[ i ] _string = string.gsub( _string, _t[ 1 ], _t[ 2 ] ) end y luego haciéndole un string.reverse quedaría perfecto Link to comment
Enargy, Posted September 21, 2016 Share Posted September 21, 2016 On 20/9/2016 at 3:11 PM, -Rex- said: y luego haciéndole un string.reverse quedaría perfecto y luego haciéndole un hash 'sha512' quedaría perfecto Link to comment
-Rex- Posted September 22, 2016 Share Posted September 22, 2016 2 hours ago, Gaberiel said: y luego haciéndole un hash 'sha512' quedaría perfecto OMG Link to comment
Tomas Posted September 22, 2016 Share Posted September 22, 2016 Puedes utilizar la función hash y combinar los algoritmos. Aquí tienes un ejemplo (que funciona) de lo que querías hacer en un principio: ----------------------------------------->> -- GTI: Grand Theft International -- Date: 30 Nov 2013 -- Resource: GTIaccounts/encryption.slua -- Type: Server Side -- Author: JT Pennington (JTPenn) ----------------------------------------->> local encryption = { ["A"]="H", ["B"]="O", ["C"]="d", ["D"]="6", ["E"]="{", ["F"]="i", ["G"]=":", ["H"]="a", ["I"]=">", ["J"]="V", ["K"]="D", ["L"]="w", ["M"]="u", ["N"]="k", ["O"]="G", ["P"]="+", ["Q"]="<", ["R"]="q", ["S"]="J", ["T"]="I", ["U"]="0", ["V"]="o", ["W"]="Z", ["X"]="/", ["Y"]="A", ["Z"]="7", ["a"]="K", ["b"]="m", ["c"]="e", ["d"]="'", ["e"]="z", ["f"]="b", ["g"]="F", ["h"]="l", ["i"]="P", ["j"]="S", ["k"]="2", ["l"]="N", ["m"]="1", ["n"]="M", ["o"]="x", ["p"]="h", ["q"]="]", ["r"]="_", ["s"]=".", ["t"]="?", ["u"]="^", ["v"]="E", ["w"]=",", ["x"]="4", ["y"]="n", ["z"]="r", ["1"]="c", ["2"]="y", ["3"]="g", ["4"]="$", ["5"]="R", ["6"]="s", ["7"]="T", ["8"]="@", ["9"]="#", ["0"]="=", ["!"]="j", ["@"]="!", ["#"]="Q", ["$"]="B", ["%"]="C", ["^"]="5", ["&"]="X", ["*"]=")", ["("]="t", [")"]="-", ["-"]="f", ["="]="W", ["_"]="(", ["+"]="8", ["["]="Y", ["]"]="3", ["{"]="P", ["}"]="*", ["|"]="}", [";"]="[", ["'"]="%", [":"]="9", [","]="&", ["."]="L", ["/"]="v", ["<"]="|", [">"]=";", ["?"]="U", ["`"]="~", ["~"]="`", ["€"]="€", } function encryptPassword(pWord) local password = {} local i = 0 for c in pWord:gmatch"." do i = i+1 table.insert(password, i, c) end local newPassword = {} for i,v in ipairs(password) do for k2,v2 in pairs(encryption) do if v == k2 then table.insert(newPassword, i, v2) break end end end local newPassword = table.concat(newPassword, "") return newPassword end function decryptPassword(pWord) local password = {} local i = 0 for c in pWord:gmatch"." do i = i+1 table.insert(password, i, c) end local newPassword = {} for i,v in ipairs(password) do for k2,v2 in pairs(encryption) do if v == v2 then table.insert(newPassword, i, k2) break end end end local newPassword = table.concat(newPassword, "") return newPassword end 1 Link to comment
Recommended Posts