mirror of
https://github.com/Luzifer/wasm-openssl.git
synced 2025-03-15 02:17:43 +00:00
Update example / demo for new API
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
6765123358
commit
5ea2270568
1 changed files with 5 additions and 13 deletions
|
@ -63,17 +63,7 @@
|
||||||
<script src="https://cdn.jsdelivr.net/combine/npm/vue@2.6.10,npm/bootstrap-vue@2.0.0-rc.28/dist/bootstrap-vue.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/combine/npm/vue@2.6.10,npm/bootstrap-vue@2.0.0-rc.28/dist/bootstrap-vue.min.js"></script>
|
||||||
<script src="wasm_exec.js"></script>
|
<script src="wasm_exec.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function decryptResponse(plaintext, error) {
|
// Define callback to be executed when openssl.wasm was initialized
|
||||||
console.log(["decryptResponse", plaintext, error])
|
|
||||||
}
|
|
||||||
|
|
||||||
function encryptResponse(ciphertext, error) {
|
|
||||||
console.log(["encryptResponse", ciphertext, error])
|
|
||||||
if (error === null) {
|
|
||||||
opensslDecrypt(ciphertext, "password", decryptResponse)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function opensslLoaded() {
|
function opensslLoaded() {
|
||||||
app.$data.loaded = true
|
app.$data.loaded = true
|
||||||
}
|
}
|
||||||
|
@ -91,24 +81,26 @@
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
decrypt() {
|
decrypt() {
|
||||||
opensslDecrypt(this.ciphertext, this.passphrase, (plaintext, err) => {
|
OpenSSL.decrypt(this.ciphertext, this.passphrase, (plaintext, err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.error = err
|
this.error = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.plaintext = plaintext
|
this.plaintext = plaintext
|
||||||
|
this.error = ''
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
encrypt() {
|
encrypt() {
|
||||||
opensslEncrypt(this.plaintext, this.passphrase, (ciphertext, err) => {
|
OpenSSL.encrypt(this.plaintext, this.passphrase, (ciphertext, err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.error = err
|
this.error = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ciphertext = ciphertext
|
this.ciphertext = ciphertext
|
||||||
|
this.error = ''
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue