5 changed files with 1840 additions and 9 deletions
File diff suppressed because it is too large
@ -0,0 +1,45 @@ |
|||
<template> |
|||
<div style="margin-left: 500px;"> |
|||
<Input v-model="ciphertext" placeholder="Enter something..." style="width: 500px"></Input> |
|||
<Button @click="decryptDES" type="primary">加密</Button> |
|||
<Button @click="decryptDES" type="primary">解密</Button><br> |
|||
<Input v-model="str" placeholder="" type="textarea" :autosize="{ minRows: 2, maxRows: 20 }" style="width: 500px"></Input> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
import CryptoJS from 'crypto-js'; |
|||
export default { |
|||
data () { |
|||
return { |
|||
key: 'o08YQii9QF5MuzYj', |
|||
message: "ZZZZZZ", |
|||
ciphertext: "", |
|||
str: "" |
|||
} |
|||
}, |
|||
methods: { |
|||
// 加密 |
|||
encryptDES () { |
|||
|
|||
var encrypt = CryptoJS.DES.encrypt(this.message, CryptoJS.enc.Utf8.parse(this.key), { |
|||
mode: CryptoJS.mode.ECB, |
|||
padding: CryptoJS.pad.Pkcs7 |
|||
}); |
|||
let str = encrypt.toString(); |
|||
console.log(str) |
|||
|
|||
}, |
|||
|
|||
// 解密 |
|||
decryptDES () { |
|||
let decrypted = CryptoJS.DES.decrypt({ ciphertext: CryptoJS.enc.Hex.parse(this.ciphertext) }, CryptoJS.enc.Utf8.parse(this.key), { |
|||
mode: CryptoJS.mode.ECB, |
|||
padding: CryptoJS.pad.Pkcs7 |
|||
}); |
|||
this.str = decrypted.toString(CryptoJS.enc.Utf8); |
|||
|
|||
|
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
Loading…
Reference in new issue