package p002a1;

import p039m1.C1468e;
import p039m1.C1470g;
import p057s1.C1621c;

/* renamed from: a1.a */
/* loaded from: classes.dex */
public final class C0040a {

    /* renamed from: a */
    public static final C0040a f18a = new C0040a();

    /* renamed from: a1.a$a */
    /* loaded from: classes.dex */
    public static abstract class AbstractC0041a {

        /* renamed from: a */
        public final int f19a;

        /* renamed from: a1.a$a$a */
        /* loaded from: classes.dex */
        public static final class C0042a extends AbstractC0041a {

            /* renamed from: b */
            public static final C0042a f20b = new C0042a();

            public C0042a() {
                super(1, null);
            }
        }

        public AbstractC0041a(int i) {
            this.f19a = i;
        }

        public /* synthetic */ AbstractC0041a(int i, C1468e c1468e) {
            this(i);
        }

        /* renamed from: a */
        public final int m5033a() {
            return this.f19a;
        }
    }

    /* renamed from: a */
    public final void m5037a(byte[] bArr, String str) {
        C1470g.m1292e(bArr, "<this>");
        C1470g.m1292e(str, "key");
        byte[] bytes = str.getBytes(C1621c.f3741b);
        C1470g.m1293d(bytes, "this as java.lang.String).getBytes(charset)");
        m5034d(bArr, bytes, AbstractC0041a.C0042a.f20b);
    }

    /* renamed from: b */
    public final byte[] m5036b(String str, String str2) {
        C1470g.m1292e(str, "<this>");
        C1470g.m1292e(str2, "key");
        byte[] bytes = str.getBytes(C1621c.f3741b);
        C1470g.m1293d(bytes, "this as java.lang.String).getBytes(charset)");
        m5037a(bytes, str2);
        return bytes;
    }

    /* renamed from: c */
    public final byte m5035c(byte b, byte b2, AbstractC0041a abstractC0041a) {
        byte m5033a = (byte) (abstractC0041a.m5033a() * (b2 % 8));
        if (m5033a < 0) {
            m5033a = (byte) (m5033a + 8);
        }
        byte b3 = (byte) (b & (-1));
        double pow = Math.pow(2.0d, m5033a);
        double d = 1;
        Double.isNaN(d);
        return (byte) (((b3 >> m5033a) | ((((int) (pow - d)) & b3) << (8 - m5033a))) & 255);
    }

    /* renamed from: d */
    public final void m5034d(byte[] bArr, byte[] bArr2, AbstractC0041a abstractC0041a) {
        int length = bArr.length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            bArr[i2] = f18a.m5035c(bArr[i], bArr2[i2 % bArr2.length], abstractC0041a);
            i++;
            i2++;
        }
    }
}