mirror of
https://github.com/Luzifer/wasm-openssl.git
synced 2025-03-14 18:17:42 +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="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 = ''
|
||||
})
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue