1
0
mirror of https://github.com/Luzifer/wasm-openssl.git synced 2024-09-16 14:38:28 +00:00

Update example / demo for new API

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-06-13 16:23:29 +02:00
parent 6765123358
commit 5ea2270568
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E

View File

@ -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="wasm_exec.js"></script>
<script>
function decryptResponse(plaintext, error) {
console.log(["decryptResponse", plaintext, error])
}
function encryptResponse(ciphertext, error) {
console.log(["encryptResponse", ciphertext, error])
if (error === null) {
opensslDecrypt(ciphertext, "password", decryptResponse)
}
}
// Define callback to be executed when openssl.wasm was initialized
function opensslLoaded() {
app.$data.loaded = true
}
@ -91,24 +81,26 @@
methods: {
decrypt() {
opensslDecrypt(this.ciphertext, this.passphrase, (plaintext, err) => {
OpenSSL.decrypt(this.ciphertext, this.passphrase, (plaintext, err) => {
if (err) {
this.error = err
return
}
this.plaintext = plaintext
this.error = ''
})
},
encrypt() {
opensslEncrypt(this.plaintext, this.passphrase, (ciphertext, err) => {
OpenSSL.encrypt(this.plaintext, this.passphrase, (ciphertext, err) => {
if (err) {
this.error = err
return
}
this.ciphertext = ciphertext
this.error = ''
})
},