Exemplo n.º 1
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"
Exemplo n.º 2
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"
Exemplo n.º 3
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"
Exemplo n.º 4
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"
Exemplo n.º 5
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"
Exemplo n.º 6
0
 def on_ok(self):
     self.output.values = [
         HachageHelper.hash(
             self.Options.get("Fonction de hachage").value[0],
             self.Options.get("Votre Message").value)
     ]