Concealing a hidden message within printed JavaScript code, waiting to be discovered

I've received a unique request from a web development company asking for 30 lines of HTML/JavaScript code to create a wall display. The code should be valid, execute in a modern browser, and display a message within 30 words (such as a clever brand slogan).

They are seeking a way to conceal the message within the code, making it appear like a visual puzzle only decipherable by those with intermediate JavaScript knowledge.

The goal is for the code to look like random text to a casual observer.

I'm open to suggestions on how to achieve this objective. I've experimented with online JavaScript minifiers and obfuscators, but they render the code unreadable. Instead, I want it to be challenging for a human coder to understand, without being impossible.

For example, if the hidden message was:

"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent quis ipsum ipsum. Donec quis lectus et ante gravida ultricies at."

How should I approach this creative challenge?

HTML/CSS, JS & JQuery are all permissible for this task.

(Moderators, please relocate this question if it doesn't belong on Stack Overflow)

Answer №1

Seems like an interesting programming puzzle, adding the twist of targeting a human code interpreter alongside valid HTML/JS/CSS.

One suggestion could be to present the message in a scrambled or fragmented manner, followed by showcasing some code that unscrambles the message. For instance:

var a = [" consectetur", 
         "dolor", 
         "Lorem ipsum ", 
         " sit amet,"];
return a[2] + a[1] + a[3] + a[0];

This complexity could be enhanced (and made more challenging to decipher) by scattering the relevant string pieces among other code snippets, incorporating conditionals to concatenate variables selectively, allowing logic or computation to determine array indexes, and so forth...

Here's an example where the encoded message is subtly embedded within the code itself:

<script id="codeblock">
  
  //JavaScript

  function getHTML(id) {
    return document.getElementById(id).innerHTML;
  }
  
  var myFavorites = [
    'No Woman No Cry',
    'Exodus',
    'Is This Love',
    'Buffalo Solder',
    'Could You Be Loved'
  ];
  
  var didYouGetTheMessage = (function(letters){
    var x = letters.split(''),
        y = myFavorites,
        z = getHTML('codeblock').split('\/\/')[1];
    x.reverse();
    return [x[17],
            y[2].slice(-4), 
            z.slice(0, 10)]
    .join(' ');
  })('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  
  //If you still did not get it ...
  console.log(didYouGetTheMessage);
  
</script>

The challenge here would likely involve striking a balance between creating a sufficiently engaging and enjoyable decoding task for humans while ensuring it does not become overly laborious.

Answer №2

To prevent the direct visibility of a message in the page source, one method is to encrypt the text and save it as a variable within the script. The decryption can then be done only when necessary for display. This approach ensures that individuals inspecting the source will not easily decipher the exact content displayed on the webpage. However, those skilled in JavaScript may still be able to understand the process being used to reveal the message.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Npm publish seems to be stuck without generating any output

I'm having trouble trying to publish a package that I created. The files can be found at this Github Repo. When I run the command npm publish, it just seems to hang without any errors or output. I've attempted logging in using npm login and npm a ...

The function req.isAuthenticated() always returns false and never evaluates to true

My goal is to create user authentication using the following code: userRouter.post("/login", passport.authenticate("local", { session: false }), (req, res) => { if (req.isAuthenticated()) { const { _id, username } = req.user; const t ...

What methods can be used to customize the font and background color of a website for different user groups?

Trying to incorporate a template into my project. My client has requested the following: The regular user area should feature a blue background. The professional user area should have an orange background. Is there a way to set up a condition to change ...

Arranging ng-grid by a hidden column

Imagine having an array of objects structured like this: { name: ... age: ... dept: ... } Now, if you want to display these objects in an ng-grid with only columns for name and age, you can set it up like this: columnDefs: [{field:'name' ...

Tips for creating a shift function without using the splice method

I'm currently working on creating custom functions for common array operations. I've hit a roadblock trying to reimplement the shift method without using splice. Any tips or guidance on how to approach this challenge would be highly valued. Cust ...

Tips for organizing and securing downloaded zip files from external websites

I am currently developing an application using CodeIgniter framework. I have a requirement to only download files with a .zip extension and upload them to my local drive. In order to achieve this, I have been provided with a function called get_zip_content ...

Querying with complex aggregations in MongoDB for sorting operations

Can anyone help me with sorting a list of accommodations based on price and number of amenities they offer? The main challenges are converting the price (which is in string format starting with $) to an integer for proper sorting, and determining the cou ...

Dealing with the notorious AngularJS error: $rootScope:infdig while using ng-style function within ng-repeat

I'm currently working on an animation for displaying phrases randomly on the main page of a website, complete with fade and translate effects. To achieve this, I am using the ng-style attribute within an ng-repeat attribute, and setting the ng-style ...

JavaScript for validating forms in PHP

Hey everyone, I'm struggling to understand why the alert box isn't showing up when I run this code. I'm new to programming and find HTML easy, but I'm currently in a PHP class where we have been tasked with creating and validating a for ...

Having trouble getting the slideup Jquery function to work properly?

Having trouble with the Slideup jquery function. $(".close_basket").click(function() { $(".mybasket").slideUp(1000); }); Here is the HTML code: <div class="mybasket"> (more code...) <div class="close_basket"> <span>Close & ...

Styling for Ajax Forms when traditional methods don't work

I'm working on an Ajax form and I want to ensure there's a solid fallback in case the user has JavaScript disabled. Currently, the form functions without JavaScript, but the user sees the JSON string displayed as plain text without any styling du ...

Having trouble getting getStaticProps to display JSX in Next.JS

I'm currently facing an issue with rendering basic data from a locally hosted Strapi API in my Next.js project. Although the data is successfully logged in the console, I am unable to map it into JSX. Below is the API get function: export async func ...

If an error occurs later in the function, `console.log` will not function properly

While debugging some code in Express.js using console.log statements, I encountered an issue where the console.log statements do not execute if there's an error in the function, even if that error occurs after the console.log statement. This behavior ...

Launching a new popup window using jqModal

I need help with a jqModal popup window scenario. I have one main popup window that I want to close after clicking OK, and then open another popup window. How can I achieve this? The issue I am facing is that the click event is not triggering as expected. ...

Removing margins in Bootstrap 5: A step-by-step guide

Currently facing an issue with removing margins in bootstrap. I am looking to set up two graphics that indicate the under construction status of the page - one for desktop and one for mobile devices. This is what I have tried so far: <!DOCTYPE html> ...

Comparing the use of visibility: hidden with -webkit-transform: translate3d() within a PhoneGap application

Currently, I am creating a hybrid application using PhoneGap. As part of the design, I have several divs (each representing a page) that I toggle between by changing their visibility in CSS using "visibility: hidden" and "visible". However, I recently ca ...

Leveraging Font Awesome icons within a WordPress theme

After installing the flat-responsive theme, I noticed that it includes Font Awesome CSS. Additionally, there is a reference to this in the functions.php file: wp_enqueue_style( 'flat_responsive_font-awesome', get_template_directory_uri() . &apos ...

Receiving user input in ajax

I have an operational PHP page with an AJAX call. I am currently attempting to obtain user input through a text entry field and then pass it through _GET into AJAX. Here is the code snippet: <body onload="test()"> <script> function test () { v ...

Executing a dropdown menu click event using PHP and AJAX

I need to display associated data when a user selects an option from a dropdown list. Below is the code for the dropdown list: <select class="op" name="emp" id ="tab4"> <option value="">--Select--</option> <?php foreach ...

The use of jQuery's ajax() function to retrieve JSON data from a URL is resulting in a response that is

I am facing an issue where the data object received in my complete() callback is not a JSON object, but rather an [Object object]. Despite this, I can still see a string of my JSON response in data.responseText. Below is my jQuery .ajax request: $.ajax({ ...