├── src ├── util │ └── whiteSpaces.js ├── index.js ├── index.css └── components │ ├── App.js │ ├── Encoder │ └── index.js │ └── Decoder │ └── index.js ├── public ├── robots.txt ├── manifest.json └── index.html ├── README.md ├── .gitignore └── package.json /src/util/whiteSpaces.js: -------------------------------------------------------------------------------- 1 | export const whiteSpaces = ['\u200C', '\u200b']; -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "BWSED", 3 | "name": "Binary Whitespace Encoder and Decoder", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "theme_color": "#000000", 7 | "background_color": "#ffffff" 8 | } -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './components/App'; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById('root') 11 | ); 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Binary Whitespace Encoder and Decoder 2 | This project uses zero-width whitespaces and binary encoding to hide String values, the process consists of converting the String to a binary value and then mapping the 0's and 1's into specified zero-width whitespaces, which results in a zero-width string which contains all the information. 3 | 4 | This project is merely a proof of concept to some friends. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Open Sans', serif; 3 | font-size: 16px; 4 | line-height: 1.5; 5 | background: #3B3738; 6 | color: whitesmoke; 7 | overflow: hidden; 8 | } 9 | 10 | .container { 11 | margin-top: 15px; 12 | } 13 | 14 | .ourFooter { 15 | position: absolute; 16 | bottom: 0; 17 | left: 0; 18 | right: 0; 19 | text-align: center; 20 | background: #3B3738; 21 | margin-bottom: 15px; 22 | } -------------------------------------------------------------------------------- /src/components/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Decoder from './Decoder'; 3 | import Encoder from './Encoder'; 4 | 5 | function App() { 6 | return ( 7 | <> 8 |
9 |
10 |
11 | 12 | 13 |
14 |
15 |
16 |
17 |

Made with by Erik

18 |
19 | 20 | ) 21 | } 22 | 23 | export default React.memo(App); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "whitespace-encoder", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^17.0.1", 7 | "react-dom": "^17.0.1", 8 | "react-scripts": "4.0.2" 9 | }, 10 | "scripts": { 11 | "start": "react-scripts start", 12 | "build": "react-scripts build", 13 | "eject": "react-scripts eject" 14 | }, 15 | "eslintConfig": { 16 | "extends": [ 17 | "react-app", 18 | "react-app/jest" 19 | ] 20 | }, 21 | "browserslist": { 22 | "production": [ 23 | ">0.2%", 24 | "not dead", 25 | "not op_mini all" 26 | ], 27 | "development": [ 28 | "last 1 chrome version", 29 | "last 1 firefox version", 30 | "last 1 safari version" 31 | ] 32 | } 33 | } -------------------------------------------------------------------------------- /src/components/Encoder/index.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { whiteSpaces } from '../../util/whiteSpaces'; 3 | 4 | function Encoder() { 5 | const [encoded, setEncoded] = useState(''); 6 | 7 | function handleEncode(event) { 8 | const value = event.target.value; 9 | let binary = toBinary(value); 10 | binary = binary.replace(/0/g, whiteSpaces[0]).replace(/1/g, whiteSpaces[1]); 11 | 12 | setEncoded(binary); 13 | } 14 | 15 | function toBinary(input) { 16 | return Array 17 | .from(input) 18 | .reduce((acc, char) => acc.concat(char.charCodeAt().toString(2)), []) 19 | .map(bin => '0'.repeat(8 - bin.length) + bin) 20 | .join(''); 21 | } 22 | 23 | return ( 24 |
25 |
26 |
27 |

Encode...

28 |

Enter any sequence and we will weird it out for you!

29 | 30 | {encoded && <> 31 | Output: -{encoded}- 32 | } 33 |
34 |
35 |
36 | ) 37 | } 38 | 39 | export default Encoder; -------------------------------------------------------------------------------- /src/components/Decoder/index.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { whiteSpaces } from '../../util/whiteSpaces'; 3 | 4 | const matcher = /([10]{8}|\s+)/g; 5 | 6 | function Decoder() { 7 | const [decoded, setDecoded] = useState(''); 8 | 9 | function handleDecode(event) { 10 | const value = event.target.value; 11 | let binary = value.replace(/-/g, '').replace(new RegExp(whiteSpaces[0], 'g'), '0').replace(new RegExp(whiteSpaces[1], 'g'), '1'); 12 | setDecoded(fromBinary(binary)); 13 | } 14 | 15 | function fromBinary(input) { 16 | if (!input || input.length === 0) return; 17 | if (!input.match(matcher)) return; 18 | 19 | return input.match(matcher).map(function (fromBinary) { 20 | return String.fromCharCode(parseInt(fromBinary, 2)); 21 | }).join(''); 22 | } 23 | 24 | return ( 25 |
26 |
27 |
28 |

Decode...

29 |

Enter an encoded string (with the hyphens) and we'll show you the output!

30 | 31 | {decoded && <> 32 | Output: {decoded} 33 | } 34 |
35 |
36 |
37 | ) 38 | } 39 | 40 | export default Decoder; -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 25 | 26 | 27 | Binary Whitespace Encoder/decoder 28 | 29 | 30 | 31 | 32 |
33 | 43 | 44 | 45 | --------------------------------------------------------------------------------