我想在Java服務器和Android客戶端之間做一些加密工作。經過一番研究,並使用PBEWithMD5AndDES算法進行Java加密
這裏是我的加密設置:
public static String encryptionAlgoirthm = "DES";
public static short encryptionBitCount = 128;
public static String hashingAlgorithm = "PBEWithMD5AndDES";
public static short hashingCount = 512;
public static String cipherTransformation = "DES/CBC/PKCS5Padding";
但是,試圖在我的CentOS VPS運行服務器時,我得到如下:
Algorithm [PBEWithMD5AndDES] of type [SecretKeyFactory] from provider [gnu.javax.security.auth.callback.GnuCallbacks: name=GNU-CALLBACKS version=2.1] is not found.
這裏是代碼:
KeySpec keySpec = new PBEKeySpec(EncryptionSettings.password, EncryptionSettings.salt, EncryptionSettings.hashingCount, EncryptionSettings.encryptionBitCount);
SecretKey tmpKey = null;
try
{
tmpKey = SecretKeyFactory.getInstance(EncryptionSettings.hashingAlgorithm).generateSecret(keySpec);
}
catch (final InvalidKeySpecException e)
{
Console.writeFatalError("Unable to generate key: invalid key specification");
}
catch (final NoSuchAlgorithmException e)
{
Console.writeFatalError("Unable to generate key: encryption algorithm not supported - " + e.getMessage());
}
我該如何解決這個問題?
如果你粘貼的代碼,那麼你拼錯「'encryptionAlgoirthm'」 – rossum 2012-01-10 12:36:10