Jump to content

Cifrado de contraseñas propio


aka Blue

Recommended Posts

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
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

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

 

  • Like 1
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...