Criptografia - Necesito invertir este algoritmo

 
Vista:

Necesito invertir este algoritmo

Publicado por jhesz (1 intervención) el 28/09/2009 20:19:55
hola tengo estos datos para saber cual el tipo de encryptacion por favor ayudenme.

var table64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

function decodeBlock(Source)
{
var x = 0;
for (var i = 0; i < 4; i++)
{
ch = Source.charAt(i);
if (ch != '=')
{
var index = table64.indexOf(ch);
if (index != - 1)
{
x = (x << 6) + index;
}
}
else
{
x = (x << 6);
}
}

dest2 = String.fromCharCode(x & 255);
x >>= 8;
dest1 = String.fromCharCode(x & 255);
x >>= 8;
dest0 = String.fromCharCode(x & 255);
x >>= 8;
var Destination = dest0 + dest1 + dest2;

return Destination;
}

function passwdDecode(Source)
{
var length = 0, equalsTerm = 0;
var Destination = '';
var i = 0;

if (Source == '')
{
return '';
}

while ((Source.charAt(length) != '=') && (length < Source.length))
{
length++;
}
while (Source.charAt(length + equalsTerm) == '=')
{
equalsTerm++;
}

var numBlocks = Math.floor((length + equalsTerm) / 4);

for (i = 0; i < numBlocks - 1; i++)
{
Destination += decodeBlock(Source.substr(i * 4, 4));
}

var lastBlock = '';
lastBlock = decodeBlock(Source.substr(i * 4, 4));
for (i = 0; i < 3-equalsTerm; i++)
{
Destination += lastBlock.charAt(i);
}

return Destination;
}

function passwdEncode(Source)
{
var sbuf = new Array();
var dbuf = new Array();
var i;
var SourceParts;
var index = 0;
var Destination = '';

var length = Source.length;
while (length > 0)
{
for (i = SourceParts = 0; i < 3; i++)
{
if (length > 0)
{
SourceParts++;
sbuf[i] = Source.charAt(index).charCodeAt(0);
index++;
length--;
}
else
{
sbuf[i] = 0;
}
}

dbuf[0] = (sbuf[0] & 0xFC) >> 2;
dbuf[1] = ((sbuf[0] & 0x03) << 4) | ((sbuf[1] & 0xF0) >> 4);
dbuf[2] = ((sbuf[1] & 0x0F) << 2) | ((sbuf[2] & 0xC0) >> 6);
dbuf[3] = sbuf[2] & 0x3F;
switch (SourceParts)
{
case 1:
Destination += table64.charAt(dbuf[0]) + table64.charAt(dbuf[1]) + "==";
break;
case 2:
Destination += table64.charAt(dbuf[0]) + table64.charAt(dbuf[1]) + table64.charAt(dbuf[2]) + "=";
break;
default:
Destination += table64.charAt(dbuf[0]) + table64.charAt(dbuf[1]) + table64.charAt(dbuf[2]) + table64.charAt(dbuf[3]);
break;
}
}

return Destination;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Necesito invertir este algoritmo

Publicado por Swicher (3 intervenciones) el 23/04/2011 09:57:34
Por lo que veo tu código es algo en Javascript que codifica y decodifica Base64. Para saber mas sobre Base64 puedes revisar en http://es.wikipedia.org/wiki/Base64
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar