Skip to content

Commit

Permalink
Replace MD5 library
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Dec 29, 2022
1 parent 039727a commit 1d0850a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 792 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = {
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
allowImportExportEverywhere: true,
},
extends: ["plugin:vue/recommended"],
env: {
Expand Down
5 changes: 0 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1123,11 +1123,6 @@ function cordova_execbrowserify(file) {
const destpath = file.replace(filename, '');
console.log(`Include required modules in ${file}`);
return browserify(file, { ignoreMissing: true })
.transform("babelify", {
presets: ["@babel/preset-env"],
sourceMaps: false,
global:true,
ignore: [/\/node_modules\/(?!md5.js\/)/] })
.bundle()
.pipe(source(filename))
.pipe(gulp.dest(destpath));
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@panter/vue-i18next": "^0.15.2",
"bluebird": "^3.7.2",
"bonjour": "^3.5.0",
"crypto-es": "^1.2.7",
"djv": "^2.1.4",
"dompurify": "^2.4.0",
"i18next": "^19.0.0",
Expand All @@ -67,7 +68,6 @@
"jquery-ui-npm": "^1.12.0",
"lru_map": "^0.3.3",
"marked": "^4.1.1",
"md5.js": "^1.3.5",
"multicast-dns": "^7.2.5",
"multiple-select": "^1.5.2",
"nw-vue-devtools-prebuilt": "^0.0.10",
Expand All @@ -82,8 +82,6 @@
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-env": "^7.20.2",
"@quanle94/innosetup": "^6.0.2",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-commonjs": "^24.0.0",
Expand All @@ -94,7 +92,6 @@
"@storybook/addon-links": "^6.5.12",
"@storybook/vue": "^6.5.12",
"babel-loader": "^8.2.5",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"chai": "^4.3.6",
"command-exists": "^1.2.9",
Expand Down
9 changes: 5 additions & 4 deletions src/js/tabs/receiver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { i18n } from "../localization";
import GUI from '../gui';

const MD5 = require('md5.js');
import { MD5 } from 'crypto-es/lib/md5.js';

const receiver = {
rateChartHeight: 117,
Expand All @@ -27,14 +27,15 @@ receiver.initialize = function (callback) {
ConfigStorage.set({'passphrase_map': passphraseMap});
}

const fromHexString = (hexString) => Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));

function elrs_passphrase_to_bytes(text) {
let uidBytes = [0,0,0,0,0,0];

if (text) {
const bindingPhraseFull = `-DMY_BINDING_PHRASE="${text}"`;
const md5stream = new MD5();
md5stream.end(bindingPhraseFull);
const buffer = md5stream.read().subarray(0, 6);
const hash = MD5(bindingPhraseFull).toString();
const buffer = fromHexString(hash).subarray(0, 6);
uidBytes = Uint8Array.from(buffer);
}

Expand Down
Loading

0 comments on commit 1d0850a

Please sign in to comment.