Skip to content

Commit

Permalink
Merge pull request #9 from hmerritt/dev/2.0.0
Browse files Browse the repository at this point in the history
Major refactor v2.0.0
  • Loading branch information
hmerritt authored Jul 26, 2023
2 parents ab60c91 + 94bb558 commit aa7e356
Show file tree
Hide file tree
Showing 24 changed files with 2,795 additions and 681 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.env
.env.local

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

node_modules/
npm-debug.log
yarn-error.log

bundle/*
output/*
bundle.js
output.js
bundle.js.map
output.js.map
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
57 changes: 40 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
# Discord Encryption

> We're back baby :)
An experimental encryption solution for Discord using [BetterDiscord](https://github.com/rauenzi/BetterDiscordApp/releases)

## Features

Adds ability to encrypt / decrypt messages on discord using a set password
- Utilizes AES-256 encryption via the [stanford javascript crypto library](https://github.com/bitwiseshiftleft/sjcl)
- Per-chat PSK
- PSK saved as md5 (cleartext passwords not present in localStorage)
- Messages are decrypted the moment they are receved with little to no delay
- Encrypted messages appear as green
- Messages that fail to be decrypted (most likely due to an incorrect password) display a message and appear as red

- Utilizes AES-256 encryption via the [stanford javascript crypto library](https://github.com/bitwiseshiftleft/sjcl)
- Per-chat PSK
- PSK saved as md5 (cleartext passwords not present in localStorage)
- Messages are decrypted the moment they are receved with little to no delay
- Encrypted messages appear as green
- Messages that fail to be decrypted (most likely due to an incorrect password) display a message and appear as red

![Context](https://i.imgur.com/aKGUqEn.png)
![Context](https://i.imgur.com/FqfRAAO.png)

## How to use

### Install
- Install Discord
- Install BetterDiscord
- Navigate to Discord Preferences -> BD/Plugins -> Open Plugin Folder
- Place 'encryption.plugin.js' in BetterDiscord's plugin folder
- Enable encryption in the BD/Plugins preference pane.

- Install Discord
- Install BetterDiscord
- Navigate to Discord Preferences -> BD/Plugins -> Open Plugin Folder
- Place 'encryption.plugin.js' in BetterDiscord's plugin folder
- Enable encryption in the BD/Plugins preference pane.

> It may ask to install an additional plugin `0PluginLibrary.plugin` which is required - It should install itself if you click `download`.
![Context](https://i.imgur.com/H2Z7N7I.png)
![Context](https://i.imgur.com/Ea0AdqO.png)
### Usage
- To toggle the encryption simply click the lock icon. You will be prompted for a password, if none is found for the chat channel.
- Received messages are decrypted automatically
- To view or change the encryption password simply right-click the lock icon and an input box will appear - passwords are automatically saved as you type

![Context](https://i.imgur.com/Zumi9SZ.png)
### Usage

## Bugs
- To toggle the encryption simply click the lock icon. You will be prompted for a password, if none is found for the chat channel.
- Received messages are decrypted automatically
- To view or change the encryption password simply right-click the lock icon and an input box will appear - passwords are automatically saved as you type

![Context](https://i.imgur.com/Zumi9SZ.png)

### Encrypted Message

![Context](https://i.imgur.com/s8CYNJK.png)

### Decrypted Message

![Context](https://i.imgur.com/CCqW5aj.png)

## Development

This plugin uses [`rollup`](https://rollupjs.org/) to bundle what's in `src` into the final `encryption.plugin.js` script.

Getting `rollup` to work with `BetterDiscord` was a **gamechanger** as it allows the plugin to use multiple src files instead of just one. This makes development much nicer.

How to build Build:

```
$ yarn && yarn build
```

> This runs both `rollup`, and a `build-patch` script to add the required `BetterDiscord` META tags.
34 changes: 34 additions & 0 deletions build/build-patch.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');
const os = require('os');
const pathfs = require('path');
const prependFile = require('prepend-file');

const isDev = process.argv?.[2] === 'dev';
const pluginOutputFile = pathfs.join(__dirname, '../', 'encryption.plugin.js');
const betterDiscordPluginDir = `C:/Users/${os.userInfo().username}/AppData/Roaming/BetterDiscord/plugins`;

const main = async () => {
console.log(`> Patching build`);

console.log(`> Adding META data to plugin output file`);
await prependFile(pluginOutputFile, `/**
* @name Encryption
* @description Message encryption using AES-256
* @author hmerritt
* @website https://github.com/hmerritt/discord-encryption
* @source https://raw.githubusercontent.com/hmerritt/discord-encryption/master/encryption.plugin.js
*/
`);

if (isDev) {
console.log(`> Copy output file to betterDiscord plugin directory`);
fs.copyFileSync(pluginOutputFile, `${betterDiscordPluginDir}/encryption.plugin.js`);
}

console.log('> Patching complete :)');
};

(async () => {
await main();
process.exit();
})();
Loading

0 comments on commit aa7e356

Please sign in to comment.