diff --git a/src/fcrypt.js b/src/fcrypt.js
index 94804d2..5105300 100644
--- a/src/fcrypt.js
+++ b/src/fcrypt.js
@@ -16,6 +16,7 @@ export default class FCrypt {
constructor (element) {
this.container = element;
this.sessionActive = false;
+ this.sessionPassword = null;
this.id = Math.random().toString(36).substr(2, 9);
this.initialiseUI();
this.setEventListeners();
@@ -48,10 +49,8 @@ export default class FCrypt {
return (
`
-
Remodal
-
- Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative configuration and hash tracking.
-
+
FCrypt | Encrypt your chat session
+
@@ -64,11 +63,11 @@ export default class FCrypt {
}
encryptString (string) {
- return CYPHER_PREFIX + CryptoJS.AES.encrypt(string, 'testing123');
+ return CYPHER_PREFIX + CryptoJS.AES.encrypt(string, this.sessionPassword);
}
decryptCypher (cypherText) {
- let decrypted = CryptoJS.AES.decrypt(cypherText.substring(CYPHER_PREFIX.length), 'testing123');
+ let decrypted = CryptoJS.AES.decrypt(cypherText.substring(CYPHER_PREFIX.length), this.sessionPassword);
return decrypted.toString(CryptoJS.enc.Utf8);
}
@@ -84,6 +83,8 @@ export default class FCrypt {
$(document).on('confirmation', `[data-remodal-id="modal-${this.id}"]`, () => {
this.sessionActive = true;
+ let password = $(`[data-remodal-id="modal-${this.id}"]`).find('.fcrypt_password_field').val();
+ this.sessionPassword = password;
this.render();
});