Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wpforms-.../assets/js/admin/share
File: xor.js
/* global define */
[0] Fix | Delete
[1] Fix | Delete
/* eslint-disable */
[2] Fix | Delete
/**
[3] Fix | Delete
* XOR, or exclusive or, is a logical bitwise operation that stands for "exclusive or."
[4] Fix | Delete
* In the context of binary numbers, XOR compares corresponding bits of two operands and
[5] Fix | Delete
* produces a new result. The XOR operation returns true (or 1) for bits where the operands differ.
[6] Fix | Delete
*
[7] Fix | Delete
* Note: This class is a simple obfuscation technique and should not be used for securing sensitive data.
[8] Fix | Delete
*
[9] Fix | Delete
* Here's the truth table for XOR:
[10] Fix | Delete
*
[11] Fix | Delete
* A | B | A XOR B
[12] Fix | Delete
* -----------------
[13] Fix | Delete
* 0 | 0 | 0
[14] Fix | Delete
* 0 | 1 | 1
[15] Fix | Delete
* 1 | 0 | 1
[16] Fix | Delete
* 1 | 1 | 0
[17] Fix | Delete
*
[18] Fix | Delete
* In binary, XOR is often denoted by the symbol ^.
[19] Fix | Delete
* Here's an example of XOR operation on binary numbers:
[20] Fix | Delete
*
[21] Fix | Delete
* 1101 (13 in decimal)
[22] Fix | Delete
* ^ 1010 (10 in decimal)
[23] Fix | Delete
* ------------------------
[24] Fix | Delete
* 0111 (7 in decimal)
[25] Fix | Delete
*
[26] Fix | Delete
* Example Usage:
[27] Fix | Delete
*
[28] Fix | Delete
* // Instantiate the plugin with a custom encryption key.
[29] Fix | Delete
* const xorInstance = new WPFormsXOR({
[30] Fix | Delete
* key: 55, // Use any number as the encryption key.
[31] Fix | Delete
* });
[32] Fix | Delete
*
[33] Fix | Delete
* // Example object to encrypt.
[34] Fix | Delete
* const dataToEncrypt = {
[35] Fix | Delete
* age: 30,
[36] Fix | Delete
* name: 'Sullie',
[37] Fix | Delete
* city: 'Texas',
[38] Fix | Delete
* };
[39] Fix | Delete
*
[40] Fix | Delete
* // Encrypt the object.
[41] Fix | Delete
* const encryptedValue = xorInstance.encrypt(dataToEncrypt);
[42] Fix | Delete
* console.log('Encrypted:', encryptedValue);
[43] Fix | Delete
*
[44] Fix | Delete
* // Decrypt the string.
[45] Fix | Delete
* const decryptedObject = xorInstance.decrypt(encryptedValue);
[46] Fix | Delete
* console.log('Decrypted:', decryptedObject);
[47] Fix | Delete
*/
[48] Fix | Delete
/* eslint-enable */
[49] Fix | Delete
[50] Fix | Delete
( function( root, factory ) {
[51] Fix | Delete
const pluginName = 'WPFormsXOR';
[52] Fix | Delete
[53] Fix | Delete
if ( typeof define === 'function' && define.amd ) {
[54] Fix | Delete
define( [], factory( pluginName ) );
[55] Fix | Delete
} else if ( typeof exports === 'object' ) {
[56] Fix | Delete
module.exports = factory( pluginName );
[57] Fix | Delete
} else {
[58] Fix | Delete
root[ pluginName ] = factory( pluginName );
[59] Fix | Delete
}
[60] Fix | Delete
// eslint-disable-next-line max-lines-per-function
[61] Fix | Delete
}( this, function( pluginName ) {
[62] Fix | Delete
// eslint-disable-next-line strict
[63] Fix | Delete
'use strict';
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Plugin Error Object.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 1.8.6
[69] Fix | Delete
*
[70] Fix | Delete
* @class PluginError
[71] Fix | Delete
*
[72] Fix | Delete
* @augments Error
[73] Fix | Delete
*/
[74] Fix | Delete
class PluginError extends Error {
[75] Fix | Delete
/**
[76] Fix | Delete
* Constructor.
[77] Fix | Delete
*
[78] Fix | Delete
* @since 1.8.6
[79] Fix | Delete
*
[80] Fix | Delete
* @param {string} message The error message.
[81] Fix | Delete
*/
[82] Fix | Delete
constructor( message ) {
[83] Fix | Delete
super( message );
[84] Fix | Delete
[85] Fix | Delete
this.name = pluginName;
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Plugin Object.
[91] Fix | Delete
*
[92] Fix | Delete
* @since 1.8.6
[93] Fix | Delete
*
[94] Fix | Delete
* @class Plugin
[95] Fix | Delete
*/
[96] Fix | Delete
class Plugin {
[97] Fix | Delete
// Default settings.
[98] Fix | Delete
static defaults = {
[99] Fix | Delete
// The encryption key is a crucial component in encryption algorithms,
[100] Fix | Delete
// including the XOR encryption used in the provided code.
[101] Fix | Delete
// The key is a value used to control the transformation
[102] Fix | Delete
// of the data during encryption and decryption.
[103] Fix | Delete
key: 42, // You can use any number.
[104] Fix | Delete
};
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Constructor.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 1.8.6
[110] Fix | Delete
*
[111] Fix | Delete
* @param {Object} args The argument object.
[112] Fix | Delete
*/
[113] Fix | Delete
constructor( args ) {
[114] Fix | Delete
// Merge the default settings with the provided settings.
[115] Fix | Delete
this.args = Object.assign( {}, Plugin.defaults, args );
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Encrypt an object using XOR encryption.
[120] Fix | Delete
*
[121] Fix | Delete
* @since 1.8.6
[122] Fix | Delete
*
[123] Fix | Delete
* @param {Object} obj The object to encrypt.
[124] Fix | Delete
*
[125] Fix | Delete
* @return {string} The encrypted object as a string.
[126] Fix | Delete
*/
[127] Fix | Delete
encrypt( obj ) {
[128] Fix | Delete
// Bail if the input is not an object.
[129] Fix | Delete
if ( typeof obj !== 'object' ) {
[130] Fix | Delete
throw new PluginError( 'Invalid input. Expected an object for encryption.' );
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
// Initialize an empty string to store the encrypted result.
[134] Fix | Delete
let result = '';
[135] Fix | Delete
[136] Fix | Delete
try {
[137] Fix | Delete
// Convert the object to a JSON string.
[138] Fix | Delete
const jsonString = JSON.stringify( obj );
[139] Fix | Delete
[140] Fix | Delete
// Iterate through each character of the JSON string.
[141] Fix | Delete
for ( let i = 0; i < jsonString.length; i++ ) {
[142] Fix | Delete
// XOR each character with the encryption key and append to the result.
[143] Fix | Delete
// eslint-disable-next-line no-bitwise
[144] Fix | Delete
result += String.fromCharCode( jsonString.charCodeAt( i ) ^ this.args.key );
[145] Fix | Delete
}
[146] Fix | Delete
} catch ( error ) {
[147] Fix | Delete
// Throw a PluginError if there's an issue during JSON stringification.
[148] Fix | Delete
throw new PluginError( 'Error during encryption. Unable to stringify the object.' );
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
return result;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
/**
[155] Fix | Delete
* Decrypt a string using XOR encryption.
[156] Fix | Delete
*
[157] Fix | Delete
* @since 1.8.6
[158] Fix | Delete
*
[159] Fix | Delete
* @param {string} encryptedString The encrypted string.
[160] Fix | Delete
*
[161] Fix | Delete
* @return {Object} The decrypted object.
[162] Fix | Delete
*/
[163] Fix | Delete
decrypt( encryptedString = '' ) {
[164] Fix | Delete
// Bail if the input is not a string.
[165] Fix | Delete
if ( typeof encryptedString !== 'string' ) {
[166] Fix | Delete
throw new PluginError( 'Invalid input. Expected a string for decryption.' );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
// Bail if there is no encrypted string.
[170] Fix | Delete
if ( ! encryptedString ) {
[171] Fix | Delete
return {}; // Return an empty object.
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
let result = '';
[175] Fix | Delete
[176] Fix | Delete
try {
[177] Fix | Delete
// Iterate through each character of the encrypted string.
[178] Fix | Delete
for ( let i = 0; i < encryptedString.length; i++ ) {
[179] Fix | Delete
// XOR each character with the decryption key and append to the result.
[180] Fix | Delete
// eslint-disable-next-line no-bitwise
[181] Fix | Delete
result += String.fromCharCode( encryptedString.charCodeAt( i ) ^ this.args.key );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
// Parse the decrypted result as JSON or return an empty object if parsing fails.
[185] Fix | Delete
return JSON.parse( result || '{}' );
[186] Fix | Delete
} catch ( error ) {
[187] Fix | Delete
// Throw an error if there's an issue during decryption or parsing.
[188] Fix | Delete
throw new PluginError( 'Error during decryption. Unable to parse decrypted data.' );
[189] Fix | Delete
}
[190] Fix | Delete
}
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
return Plugin;
[194] Fix | Delete
} ) );
[195] Fix | Delete
[196] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function