<commit_before>package net.bither.bitherj.crypto;

/**
 * Created by songchenwen on 15/1/4.
 */
public class EncryptedData {
    private byte[] encryptedData;
    private byte[] initialisationVector;
    private byte[] salt;

    public EncryptedData(String str){
        //TODO from encrypted string
    }

    public EncryptedData(byte[] dataToEncrypt, CharSequence password){
        KeyCrypterScrypt crypter = new KeyCrypterScrypt();
        salt = crypter.getSalt();
        EncryptedPrivateKey k = crypter.encrypt(dataToEncrypt, crypter.deriveKey(password));
        encryptedData = k.getEncryptedBytes();
        initialisationVector = k.getInitialisationVector();
    }

    public byte[] decrypt(CharSequence password){
        KeyCrypterScrypt crypter = new KeyCrypterScrypt(salt);
        return crypter.decrypt(new EncryptedPrivateKey(initialisationVector, encryptedData), crypter.deriveKey(password));
    }

    public String toString(){
        //TODO to string
        return null;
    }

}<commit_msg>init EncryptedData<commit_after>package net.bither.bitherj.crypto;

import net.bither.bitherj.qrcode.QRCodeUtil;
import net.bither.bitherj.utils.Utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class EncryptedData {

    private static final Logger log = LoggerFactory.getLogger(EncryptedData.class);

    private byte[] encryptedData;
    private byte[] initialisationVector;
    private byte[] salt;

    public EncryptedData(String str) {
        String[] strs = QRCodeUtil.splitOfPasswordSeed(str);
        if (strs.length != 3) {
            log.error("decryption: EncryptedData format error");
        }
        initialisationVector = Utils.hexStringToByteArray
                (strs[1]);
        encryptedData = Utils.hexStringToByteArray(strs[0]);
        salt = Utils.hexStringToByteArray(strs[2]);
    }

    public EncryptedData(byte[] dataToEncrypt, CharSequence password) {
        KeyCrypterScrypt crypter = new KeyCrypterScrypt();
        salt = crypter.getSalt();
        EncryptedPrivateKey k = crypter.encrypt(dataToEncrypt, crypter.deriveKey(password));
        encryptedData = k.getEncryptedBytes();
        initialisationVector = k.getInitialisationVector();
    }

    public byte[] decrypt(CharSequence password) {
        KeyCrypterScrypt crypter = new KeyCrypterScrypt(salt);
        return crypter.decrypt(new EncryptedPrivateKey(initialisationVector, encryptedData), crypter.deriveKey(password));
    }

    public String toString() {
        //TODO to string
        return null;
    }

}
{'fraction_non_alphanumeric': 0.09577795152462862, 'fraction_numerical': 0.003909304143862392, 'mean_word_length': 3.3969072164948453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3315803', 'n_tokens_mistral': 785, 'n_tokens_neox': 763, 'n_words': 155}