mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-08 14:10:05 +00:00
Use JS cryptocore
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7bdc430812
commit
9bd560a05a
5 changed files with 39 additions and 3 deletions
|
@ -21,7 +21,10 @@ module.exports = {
|
|||
plugins: ['vue'],
|
||||
globals: {
|
||||
Go: true,
|
||||
opensslDecrypt: true,
|
||||
opensslEncrypt: true,
|
||||
process: true,
|
||||
sha256sum: true,
|
||||
},
|
||||
// add your custom rules here
|
||||
rules: {
|
||||
|
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -6992,6 +6992,11 @@
|
|||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"gibberish-aes": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/gibberish-aes/-/gibberish-aes-1.0.0.tgz",
|
||||
"integrity": "sha1-9kHEWPuCLgrWHDwN6hWOC5Q+n8U="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
|
@ -11905,6 +11910,11 @@
|
|||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"sha2": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/sha2/-/sha2-1.0.2.tgz",
|
||||
"integrity": "sha512-sQ1sFn+WN2weGkwwt25bllwocaJLyYeDrn/T221Bovc6XEHRf7NSn0KPoPQMV2+NT+RhJoStkdm4TrEGCXkKHA=="
|
||||
},
|
||||
"shallow-clone": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz",
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
"axios": "^0.18.1",
|
||||
"bootstrap-vue": "^2.2.0",
|
||||
"bootswatch": "^4.4.1",
|
||||
"gibberish-aes": "^1.0.0",
|
||||
"sha2": "^1.0.2",
|
||||
"uuid": "^3.3.3",
|
||||
"vue": "^2.6.11",
|
||||
"vue-clipboard2": "^0.2.1",
|
||||
|
|
18
src/js_cryptocore.js
Normal file
18
src/js_cryptocore.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import GibberishAES from 'gibberish-aes/src/gibberish-aes.js'
|
||||
import { SHA256 } from 'sha2'
|
||||
|
||||
const opensslDecrypt = (plaintext, password, callback) => {
|
||||
callback(GibberishAES.enc(plaintext, password), null)
|
||||
}
|
||||
|
||||
const opensslEncrypt = (ciphertext, password, callback) => {
|
||||
callback(GibberishAES.dec(ciphertext, password), null)
|
||||
}
|
||||
|
||||
const sha256sum = (plaintext, callback) => {
|
||||
callback(SHA256(plaintext).toString('hex'))
|
||||
}
|
||||
|
||||
window.opensslDecrypt = opensslDecrypt
|
||||
window.opensslEncrypt = opensslEncrypt
|
||||
window.sha256sum = sha256sum
|
|
@ -35,9 +35,12 @@ Vue.component('fa-icon', FontAwesomeIcon)
|
|||
|
||||
axios.defaults.baseURL = 'v2'
|
||||
|
||||
const go = new Go()
|
||||
WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject)
|
||||
.then(async obj => await go.run(obj.instance))
|
||||
/*
|
||||
* const go = new Go()
|
||||
* WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject)
|
||||
* .then(async obj => await go.run(obj.instance))
|
||||
*/
|
||||
import './js_cryptocore.js' // JS alternative
|
||||
|
||||
window.instance = new Vue({
|
||||
mounted: () => store.dispatch('reload_users'),
|
||||
|
|
Loading…
Reference in a new issue