decrypt class.js
À propos du fichier
- Type de fichier
- Fichier JS de 3 Ko (text/plain)
- Confidentialité
- Fichier public, envoyé le 9 avril 2018 à 07:42, depuis l'adresse IP 154.120.x.x (MG)
- Sécurité
- Ne contient aucun Virus ou Malware connus - Dernière vérification: hier
- Statistiques
- La présente page de téléchargement a été vue 710 fois depuis l'envoi du fichier
- Page de téléchargement
-
Aperçu du fichier
'use strict';
var Decrypt = function(){
Decrypt.buildBaseKey = function(){
var baseKey = '';
for (var i = 32; i < 127; i++)
baseKey += String.fromCharCode(i);
return baseKey;
};
this.message = null;
this.key = null;
this.position = null;
this.isEncoded64 = false;
this.baseKey = Decrypt.buildBaseKey();
this.reducedBaseKey = this.baseKey.replace('[', '').replace(']', '');
}
Decrypt.prototype.withMessage = function(message){
this.message = message;
return this;
}
Decrypt.prototype.withKey = function(key){
this.key = key;
return this;
}
Decrypt.prototype.withPosition = function(position){
this.position = position;
return this;
}
Decrypt.prototype.withIsEncoded64 = function(isEncoded64){
this.isEncoded64 = isEncoded64;
return this;
}
Decrypt.prototype.decrypt = function(){
this.checkVariables();
var decompressedPositionArray = this.decrompressPositionArray();
var decryptedPositions = this.decryptPositions(decompressedPositionArray);
return this.decryptCharacters(decryptedPositions);
}
Decrypt.prototype.checkVariables = function(){
if (StringUtils.isEmpty(this.message))
throw 'No message to decrypt';
if (StringUtils.isEmpty(this.key))
throw 'No key to use';
if (StringUtils.isEmpty(this.position))
throw 'No position to use';
if (!this.isEncoded64)
return;
this.message = atob(this.message);
this.key = atob(this.key);
this.position = atob(this.position);
}
Decrypt.prototype.decrompressPositionArray = function(){
var length = this.position.length;
var decompressedPositionArray = [];
for (var i = 0; i < length; i++){
var character = this.position[i];
if (character != '['){
decompressedPositionArray.push(parseInt(this.reducedBaseKey.indexOf(this.position[i])));
continue;
}
var part = this.position.substr(i + 1);
var endPosition = part.indexOf(']');
if (endPosition < 0)
throw 'Error on decompressing position array';
decompressedPositionArray.push(parseInt(part.substring(0, endPosition)));
i += endPosition + 1;
}
return decompressedPositionArray;
}
Decrypt.prototype.decryptPositions = function(decompressedPositionArray){
var decryptedPositions = [];
var length = decompressedPositionArray.length;
var messageArray;
for (var i = length - 1; i >= 0; i--)
messageArray = ArrayUtils.insert(messageArray, this.message[i], decompressedPositionArray[i]);
return messageArray.join('');
}
Decrypt.prototype.decryptCharacters = function(decryptedPositions){
var decryptedMessage = '';
var length = decryptedPositions.length;
for (var i = 0; i < length; i++)
decryptedMessage += this.baseKey[this.key.indexOf(decryptedPositions[i])];
return decryptedMessage;
}
Partager le fichier decrypt-class.js sur le Web et les réseaux sociaux:
Télécharger le fichier decrypt-class.js
Télécharger decrypt-class.js