0% found this document useful (0 votes)
2 views2 pages

function urlEncode(str) {

The document contains JavaScript functions for various string manipulations including URL encoding, Base64 encoding, character replacement for a 'leet' effect, and string reversal. It also includes a function to enhance a string by applying all these manipulations and logging the results. The example provided tests the word 'cums' and displays the results of the manipulations performed on it.

Uploaded by

yourgrave532
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

function urlEncode(str) {

The document contains JavaScript functions for various string manipulations including URL encoding, Base64 encoding, character replacement for a 'leet' effect, and string reversal. It also includes a function to enhance a string by applying all these manipulations and logging the results. The example provided tests the word 'cums' and displays the results of the manipulations performed on it.

Uploaded by

yourgrave532
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

function urlEncode(str) {

// URL-encodes the string to make it safe for use in URLs


return encodeURIComponent(str);
}

function base64Encode(str) {
// Converts the string to Base64 format
try {
return btoa(unescape(encodeURIComponent(str)));
} catch (error) {
console.error("Error in Base64 encoding:", error);
return str; // Return original string in case of error
}
}

function replaceCharacters(str) {
// Replaces common letters with symbols to create a "leet" effect
const replacements = {
'a': '@',
'e': '3',
'i': '1',
'o': '0',
's': '$',
't': '7',
};
// Replaces characters based on the defined dictionary, returns new string
return str.split('').map(char => replacements[char.toLowerCase()] ||
char).join('');
}

function reverseString(str) {
// Reverses the string (could be a simple form of obfuscation)
return str.split('').reverse().join('');
}

function testInput(input) {
// Logs the results in a formatted way
console.log(`Testing input: "${input}"`);
}

function enhanceString(str) {
// Creates a variety of string manipulations for testing
return {
original: str,
urlEncoded: urlEncode(str),
base64Encoded: base64Encode(str),
characterReplaced: replaceCharacters(str),
reversed: reverseString(str)
};
}

// Word to test
const word = "cums"; // Changed word here

// Generating enhanced string manipulations


const enhancedWord = enhanceString(word);

// Displaying results for all strategies


for (const [strategy, result] of Object.entries(enhancedWord)) {
testInput(`${strategy}: ${result}`);
}

You might also like