Code example for IvParameterSpec

0
            byte[] aesKey = new byte[AES_BYTES];
            byte[] aesIv = new byte[aesRaw.length-aesKey.length];
            System.arraycopy(aesRaw, 0, aesKey, 0, aesKey.length);
            System.arraycopy(aesRaw, aesKey.length, aesIv, 0, aesIv.length);
            c = Cipher.getInstance("AES/CBC/PKCS7Padding");
            c.init(Cipher.DECRYPT_MODE, new SecretKeySpec(aesKey, "AES"), new IvParameterSpec(aesIv));
            byte[] dec = c.doFinal(encRaw);
             
            JSONArray res = new JSONArray();
            res.put(new String(dec, "utf-8"));
            res.put(ver);
            callback.success(res);
        } catch (Exception ex) {
            Log.w("whistle", "Decrypt error:"+ex.getMessage(), ex);
            callback.error(ex);
        } 
    } 
     
    /** 
     * Hashes a password. 
     * @param args Arguments: password, saltOrLogRounds