src/lib/Services/EncryptionService.js
/**
     * Decrypts a string with TRUBIA.
     * Salt is appended to current password to create the key for this encrypted text.
     * Such key is used to decrypt with AES.
     * Decrypted Enigma Configuration is established. The processed text is decrypted with Enigma.
     * @param {string} txt: text to encrypt.
     * @param {bool} inbox: true if encryption is for inbox.
     * @returns {string}: decrypted text.
     */
Decrypts a string with TRUBIA.
Salt is appended to current password to create the key for this encrypted text.
Such key is used to decrypt with AES.
Decrypted Enigma Configuration is established. The processed text is decrypted with Enigma.
@param {string} txt: text to encrypt.
@param {bool} inbox: true if encryption is for inbox.
@returns {string}: decrypted text.
Decrypts a string with TRUBIA . Salt is appended to current password to create the key for this encrypted text . Such key is used to decrypt with AES . Decrypted Enigma Configuration is established . The processed text is decrypted with Enigma . @param { string } txt : text to encrypt . @param { bool } inbox : true if encryption is for inbox . @returns { string } : decrypted text .
decrypt(txt, inbox) {
        var key = "";
        var salt = "";
        if (inbox) {
            key = txt.split("=")[0];
        } else {
            salt = txt.value ? txt.value.split("=")[0] : txt.split("=")[0];
            key = this.hash(this.pass + salt);
        }
        var msg = txt.value ? txt.value.replace((inbox ? key : salt) + "=", "") : txt.replace((inbox ? key : salt) + "=", "");
        var desAes = this.decryptAES(msg, key);
        if (desAes.includes(";base64,")) {
            return desAes;
        }
        var enigmaConf = desAes.split("//");
        if (enigmaConf.length > 8) {
            this.code = [enigmaConf[0], enigmaConf[1], enigmaConf[2]];
            this.plugboard = JSON.parse(enigmaConf[3]);
            this.greek = enigmaConf[4];
            this.rotor1 = enigmaConf[5];
            this.rotor2 = enigmaConf[6];
            this.rotor3 = enigmaConf[7];
            this.reflector = enigmaConf[8];
            var res = this.rotorSchlusselmaschineDekodierung(enigmaConf.slice(9, enigmaConf.length).join("//"));
            return res;
        } else {
            return txt.value ? txt.value : txt;
        }
    }
decrypt ( txt , inbox ) { var key = "" ; var salt = "" ; if ( inbox ) { key = txt . split ( "=" ) [ 0 ] ; } else { salt = txt . value ? txt . value . split ( "=" ) [ 0 ] : txt . split ( "=" ) [ 0 ] ; key = this . hash ( this . pass + salt ) ; } var msg = txt . value ? txt . value . replace ( ( inbox ? key : salt ) + "=" , "" ) : txt . replace ( ( inbox ? key : salt ) + "=" , "" ) ; var desAes = this . decryptAES ( msg , key ) ; if ( desAes . includes ( ";base64," ) ) { return desAes ; } var enigmaConf = desAes . split ( "//" ) ; if ( enigmaConf . length > 8 ) { this . code = [ enigmaConf [ 0 ] , enigmaConf [ 1 ] , enigmaConf [ 2 ] ] ; this . plugboard = JSON . parse ( enigmaConf [ 3 ] ) ; this . greek = enigmaConf [ 4 ] ; this . rotor1 = enigmaConf [ 5 ] ; this . rotor2 = enigmaConf [ 6 ] ; this . rotor3 = enigmaConf [ 7 ] ; this . reflector = enigmaConf [ 8 ] ; var res = this . rotorSchlusselmaschineDekodierung ( enigmaConf . slice ( 9 , enigmaConf . length ) . join ( "//" ) ) ; return res ; } else { return txt . value ? txt . value : txt ; } }
Decrypts a string with TRUBIA.
Decrypts a string with TRUBIA .