小编Nau*_*aal的帖子

PBKDF2WithHmacSHA1密钥生成在Android上花费太长时间

我想使用PBKDF2WithHmacSHA1生成密钥,但在android上计算需要很长时间.我在iOS上使用相同数量的迭代与常见的加密,它需要大约6秒,因为在Android上它需要100秒.

这是代码:

public static String generateStorngPasswordHash(String password)
{
    try
    {
        char[] chars = password.toCharArray();
        byte[] salt = getSalt();

        PBEKeySpec spec = new PBEKeySpec(chars, salt, 1010101, 32 * 8);
        SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        byte[] hash = skf.generateSecret(spec).getEncoded();

        return toHex(salt) + ":" + toHex(hash);
    } catch (Exception e)
    {
        Logger.e("Exception: Error in generating password" + e.toString());
    }
    return "";
}

private static byte[] getSalt() throws NoSuchAlgorithmException
{
    SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
    byte[] salt = new byte[32];
    sr.nextBytes(salt);
    return salt;
}
Run Code Online (Sandbox Code Playgroud)

如果此代码有任何问题,请告诉我?

编辑 …

android cryptography pbkdf2 sqlcipher

5
推荐指数
1
解决办法
4012
查看次数

使用volley android下载Zip文件

我想通过volley使用get调用来下载zip文件.现在,我可以使用以下方式 下载文件:在Android中下载并解压缩Zip文件.

我想改用排球库.我该怎么做?

android android-volley

5
推荐指数
1
解决办法
2534
查看次数

无法解析Intent Service Android

尝试配置推送通知时出现以下错误:

06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
Run Code Online (Sandbox Code Playgroud)

我在gradle中有不同的口味:

我的代码包名是:com.ebr.apps.ebr 我的产品风味包是:com.ebr.apps.ebr.development

我在app/src/development中放置了google-services.json

表现:

    <permission
        android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature"/>

    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>

         <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>

        <service
            android:name=".GCM.PushNotificationService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            </intent-filter>
        </service>
Run Code Online (Sandbox Code Playgroud)

我看了很多例子,但仍然遇到这个错误.

android push-notification intentservice google-cloud-messaging

5
推荐指数
1
解决办法
7939
查看次数