src/lib/Services/EncryptionService.js
/**
     * Encrypts a string with TRUBIA.
     * Firstly the target is encrypted with M4 Enigma using a random configuration.
     * Then its configuration is appended to the result. All of it is encrypted using AES.
     * Salt is appended to the encrypted text. Process completed.
     * @param {string} txt: text to encrypt.
     * @param {bool} inbox: true if encryption is for inbox.
     * @returns {string}: encrypted text along salt.
     */
Encrypts a string with TRUBIA.
Firstly the target is encrypted with M4 Enigma using a random configuration.
Then its configuration is appended to the result. All of it is encrypted using AES.
Salt is appended to the encrypted text. Process completed.
@param {string} txt: text to encrypt.
@param {bool} inbox: true if encryption is for inbox.
@returns {string}: encrypted text along salt.
Encrypts a string with TRUBIA . Firstly the target is encrypted with M4 Enigma using a random configuration . Then its configuration is appended to the result . All of it is encrypted using AES . Salt is appended to the encrypted text . Process completed . @param { string } txt : text to encrypt . @param { bool } inbox : true if encryption is for inbox . @returns { string } : encrypted text along salt .
encrypt(txt, inbox) {
        this.inbox = inbox;
        var enigmaEnc;
        if (!txt.includes(";base64,")) {
            var enc = this.rotorSchlusselmaschineCodierung(txt);
            var enigmaConf = this.code[0] + "//" + this.code[1] + "//" + this.code[2] + "//" +
                JSON.stringify(this.plugboard) + "//" + this.greek + "//" +
                this.rotor1 + "//" + this.rotor2 + "//" + this.rotor3 + "//" + this.reflector + "//";
            enigmaEnc = enigmaConf + enc;
        } else {
            enigmaEnc = txt;
        }
        return (inbox ? this.defaultkey : this.salt.toString()) + "=" + this.encryptAES(enigmaEnc);
    }
encrypt ( txt , inbox ) { this . inbox = inbox ; var enigmaEnc ; if ( ! txt . includes ( ";base64," ) ) { var enc = this . rotorSchlusselmaschineCodierung ( txt ) ; var enigmaConf = this . code [ 0 ] + "//" + this . code [ 1 ] + "//" + this . code [ 2 ] + "//" + JSON . stringify ( this . plugboard ) + "//" + this . greek + "//" + this . rotor1 + "//" + this . rotor2 + "//" + this . rotor3 + "//" + this . reflector + "//" ; enigmaEnc = enigmaConf + enc ; } else { enigmaEnc = txt ; } return ( inbox ? this . defaultkey : this . salt . toString ( ) ) + "=" + this . encryptAES ( enigmaEnc ) ; }
Encrypts a string with TRUBIA.
Encrypts a string with TRUBIA .