receivedSEK
не в Base64, но, по-видимому, какая-то "шестнадцатеричная" строка.
String receivedSEK = "0x5D112907B134B9CE30E30745F48A536845521B04F6B912552AAA65B563F01CC0";
int n = (receivedSEK.length() - 2) / 2;
byte[] bytes = new byte[n];
for (int i = 0; i < n; ++i) {
bytes[i] = (byte) Integer.parseInt(receivedSEK.substring(2 + 2*i, 4 + 2*i), 16);
}
decryptedSek = NICEncrypt.decrypt(bytes, decodeBase64StringTOByte(decrypted_appkey));
public static String decrypt(byte[] bytes, byte[] secret)
throws InvalidKeyException, IOException, IllegalBlockSizeException,
BadPaddingException, Exception {
SecretKeySpec sk = new SecretKeySpec(secret, AES_ALGORITHM);
DECRYPT_CIPHER.init(Cipher.DECRYPT_MODE, sk);
byte[] bytes = DECRYPT_CIPHER.doFinal(bytes);
return Base64.getEncoder().encodeToString(bytes);
}
private static byte[] decodeBase64StringTOByte(String stringData) throws Exception {
return Base64.getDecoder().decode(stringData);
}
Также расшифровка Base64 проще.