Exemple #1
0
    def create(self):

        self.add(npyscreen.FixedText, value="OPTIONS:")
        self.how_exited_handers[
            npyscreen.wgwidget.EXITED_ESCAPE] = self.exit_application

        self.Options = npyscreen.OptionList()
        # just for convenience so we don't have to keep writing Options.options
        options = self.Options.options

        options.append(npyscreen.OptionMultiFreeText('Votre Message',
                                                     value=''))
        options.append(
            npyscreen.OptionSingleChoice('Fonction de hachage',
                                         choices=HachageHelper.getAvailable()))

        self.add(npyscreen.OptionListDisplay,
                 name="Liste d'options",
                 values=options,
                 scroll_exit=True,
                 max_height=6)

        self.output = self.add(npyscreen.BoxTitle,
                               name="Sortie de texte:",
                               max_height=4)
        self.output.values = []

        # The menus are created here.
        self.mMain = self.add_menu(name="Menu")
        self.mMain.addItemsFromList([
            ("Retour", self.retour),
        ])
Exemple #2
0
    def dec_des(string_to_decrypt, key):
        try:
            hashed_key = HachageHelper.hash('md5', key)
            cipher = DES.new(hashed_key[:8])
            encrypted_msg = base64.b64decode(string_to_decrypt.encode())
            decrypted_msg = cipher.decrypt(encrypted_msg)

            return decrypted_msg.decode().rstrip(padding_character)
        except:
            return "Une erreur s'est produite, veuillez vérifier vos entrées"
Exemple #3
0
    def enc_des(string_to_encrypt, key):
        try:
            hashed_key = HachageHelper.hash('md5', key)
            cipher = DES.new(hashed_key[:8])
            padded_private_msg = string_to_encrypt + (padding_character * (
                (8 - len(string_to_encrypt)) % 8))
            encrypted_msg = cipher.encrypt(padded_private_msg)
            encoded_encrypted_msg = base64.b64encode(encrypted_msg)

            return encoded_encrypted_msg.decode()
        except:
            return "Une erreur s'est produite, veuillez vérifier vos entrées"
Exemple #4
0
    def dec_aes(string_to_decrypt, key):
        try:
            hashed_key = HachageHelper.hash('md5', key)
            # use the secret key to create a AES cipher
            cipher = AES.new(hashed_key)
            encrypted_msg = base64.b64decode(string_to_decrypt.encode())
            # use the cipher to decrypt the encrypted message
            decrypted_msg = cipher.decrypt(encrypted_msg)

            return decrypted_msg.decode().rstrip(padding_character)
        except:
            return "Une erreur s'est produite, veuillez vérifier vos entrées"
Exemple #5
0
    def enc_cast(string_to_encrypt, key):
        try:
            hashed_key = HachageHelper.hash('md5', key)
            # CAST key must be at least 5 bytes and no more than 16 bytes long
            cipher = CAST.new(hashed_key[:16])
            padded_private_msg = string_to_encrypt + (padding_character * (
                (8 - len(string_to_encrypt)) % 8))
            encrypted_msg = cipher.encrypt(padded_private_msg)
            encoded_encrypted_msg = base64.b64encode(encrypted_msg)

            return encoded_encrypted_msg.decode()
        except:
            return "Une erreur s'est produite, veuillez vérifier vos entrées"
Exemple #6
0
    def enc_aes(string_to_encrypt, key):
        try:
            # AES key length must be either 16, 24, or 32 bytes long
            # we will use truncated md5 (16 bytes) hash so we don't restrict the user
            hashed_key = HachageHelper.hash('md5', key)
            # use the secret key to create a AES cipher
            cipher = AES.new(hashed_key)
            # pad the private_msg
            # because AES encryption requires the length of the msg to be a multiple of 16
            padded_private_msg = string_to_encrypt + (padding_character * (
                (16 - len(string_to_encrypt)) % 16))
            # use the cipher to encrypt the padded message
            encrypted_msg = cipher.encrypt(padded_private_msg)
            # encode the encrypted msg
            encoded_encrypted_msg = base64.b64encode(encrypted_msg)

            return encoded_encrypted_msg.decode()
        except:
            return "Une erreur s'est produite, veuillez vérifier vos entrées"
Exemple #7
0
 def on_ok(self):
     self.output.values = [
         HachageHelper.crackHash(
             self.Options.get("Fonction de hachage").value[0],
             self.Options.get("Hash").value, self.wordListFile.value)
     ]
Exemple #8
0
 def on_ok(self):
     self.output.values = [
         HachageHelper.hash(
             self.Options.get("Fonction de hachage").value[0],
             self.Options.get("Votre Message").value)
     ]