<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Author: <NAME> (gaelL) <<EMAIL>>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gnupg
import logging
from os.path import join as os_join
from passkeeper.tools import *

LOG = logging.getLogger(__name__)

def encrypt(source, output, passphrase):
    gpg = gnupg.GPG()
    with open(source, 'r') as f:
        encrypted = gpg.encrypt_file(
            f,
            recipients=None,
            symmetric='AES256',
            armor=True,
            passphrase=passphrase,
            output=output)
    return encrypted


def decrypt(source, output, passphrase):
    gpg = gnupg.GPG()
    with open(source, 'r') as f:
        decrypted = gpg.decrypt_file(f,
            passphrase=passphrase,
            always_trust=True,
            output=output)
    return decrypted<commit_msg>python3 compatibility<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Author: <NAME> (gaelL) <<EMAIL>>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gnupg
import logging
from os.path import join as os_join
from passkeeper.tools import *

LOG = logging.getLogger(__name__)

def encrypt(source, output, passphrase):
    gpg = gnupg.GPG()
    with open(source, 'rb') as f:
        encrypted = gpg.encrypt_file(
            f,
            recipients=None,
            symmetric='AES256',
            armor=True,
            passphrase=<PASSWORD>,
            output=output)
    return encrypted


def decrypt(source, output, passphrase):
    gpg = gnupg.GPG()
    with open(source, 'rb') as f:
        decrypted = gpg.decrypt_file(f,
            passphrase=<PASSWORD>,
            always_trust=True,
            output=output)
    return decrypted
{'fraction_non_alphanumeric': 0.08827586206896551, 'fraction_numerical': 0.003793103448275862, 'mean_word_length': 2.9523160762942777, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7087712', 'n_tokens_mistral': 839, 'n_tokens_neox': 814, 'n_words': 322}