Skip to content

Instantly share code, notes, and snippets.

@agoldstein03
Created November 16, 2020 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agoldstein03/ec4cbef61d54a85ec46973f97d537cea to your computer and use it in GitHub Desktop.
Save agoldstein03/ec4cbef61d54a85ec46973f97d537cea to your computer and use it in GitHub Desktop.
629-character asynchronous function that, when run on an Actively Learn book page, generates a function to convert encrypted text to decrypted text
async()=>{let k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",l='eng',c=document.createElement("canvas"),t=c.getContext("2d");c.height=100;c.width=1500;t.fillStyle="#000";t.font=getComputedStyle(document.querySelector(".encrypted .textSection")).font;t.fillText(k.replace(/./g,"$& "),10,50);if(typeof Tesseract=="undefined")await import("https://unpkg.com/tesseract.js@2.0.0/dist/tesseract.min.js");const w=new Tesseract.createWorker();await w.load();await w.loadLanguage(l);await w.initialize(l);const m=new Map([...(await w.recognize(c)).data.text].map((l,i)=>[k[i],l]));return(e)=>[...e].map(l=>m.get(l)||l).join("")}
@agoldstein03
Copy link
Author

(There may be a better, more code-inspection-y way to do this, but that sort of defeats the point.)

Actively Learn uses a font to display some of their works that associates "encrypted" (simple A-Za-z substitution) characters with their displayable characters; this way the text displays normally, but when copied, the result is garbage.

This script draws the alphabet (A-Z, a-z) onto a canvas in the "encrypted" font then uses the Tesseract.js library to determine what those drawn characters are. Then, a Map is created to associate encrypted characters with decrypted characters, and a function is returned to convert text as such.

This should only be taken as a proof-of-concept (which is why it is an anonymous function and not a full application); do not use this program to bypass any copy protections in practice. This program was developed without any attempts to circumvent any copy protections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment