package com.oo.seex.oo_statistics_lib.utils.utdid.Device;


import com.oo.seex.oo_statistics_lib.utils.utdid.utils.AESUtils;
import com.oo.seex.oo_statistics_lib.utils.utdid.utils.Base64;

import java.util.Random;

public class UTUtdidHelper {
    private String mAESKey = "XwYp8WL8bm6S4wu6yEYmLGy4RRRdJDIhxCBdk3CiNZTwGoj1bScVZEeVp9vBiiIsgwDtqZHP8QLoFM6o6MRYjW8QqyrZBI654mqoUk5SOLDyzordzOU5QhYguEJh54q3K1KqMEXpdEQJJjs1Urqjm2s4jgPfCZ4hMuIjAMRrEQluA7FeoqWMJOwghcLcPVleQ8PLzAcaKidybmwhvNAxIyKRpbZlcDjNCcUvsJYvyzEA9VUIaHkIAJ62lpA3EE3H";
    private static Random random = new Random();

    public UTUtdidHelper() {
        this.mAESKey = Base64.encodeToString(this.mAESKey.getBytes(), 2);
    }

    public String pack(byte[] pUtdid) {
        String lB64String = Base64.encodeToString(pUtdid, 2);
        String lEResult = AESUtils.encrypt(this.mAESKey, lB64String);
        return lEResult;
    }

    public String packUtdidStr(String pUtdid) {
        String lEResult = AESUtils.encrypt(this.mAESKey, pUtdid);
        return lEResult;
    }

    public String dePack(String pPackedUtdid) {
        String lUtdid = AESUtils.decrypt(this.mAESKey, pPackedUtdid);
        return lUtdid;
    }

    public static String generateRandomUTDID() {
        StringBuffer sb = new StringBuffer();

        for(int i = 0; i < 24; ++i) {
            sb.append((char)(65 + random.nextInt(25)));
        }

        return sb.toString();
    }
}
