package com.adobe.marketing.mobile.internal.util;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import wg.t;

/* loaded from: classes4.dex */
public abstract class i {

    /* renamed from: a, reason: collision with root package name */
    private static final char[] f12317a = "0123456789abcdef".toCharArray();

    /* renamed from: b, reason: collision with root package name */
    private static final char[] f12318b = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF".toCharArray();

    public static long a(String str) {
        return Long.parseLong(Integer.toHexString(b(str)), 16);
    }

    private static int b(String str) {
        int i10 = (str == null || str.trim().isEmpty()) ? 0 : -2128831035;
        for (byte b10 : str.getBytes()) {
            i10 = (i10 ^ (b10 & 255)) * 16777619;
        }
        return i10;
    }

    public static String c(String str) {
        if (str != null && !str.isEmpty()) {
            try {
                MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
                messageDigest.update(str.getBytes(StandardCharsets.UTF_8));
                byte[] digest = messageDigest.digest();
                StringBuilder sb2 = new StringBuilder();
                for (byte b10 : digest) {
                    StringBuilder sb3 = new StringBuilder(Integer.toHexString(b10 & 255));
                    while (sb3.length() < 2) {
                        sb3.insert(0, "0");
                    }
                    sb2.append((CharSequence) sb3);
                }
                return sb2.toString();
            } catch (NoSuchAlgorithmException e10) {
                t.a("MobileCore", "StringEncoder", "Failed to create sha2 hash " + e10, new Object[0]);
            }
        }
        return null;
    }
}
