Code example for PKCS8EncodedKeySpec

0
 
    void setPrivateKey(byte[] bytes) {
        try { 
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            mUserKey = keyFactory.generatePrivate(
                    new PKCS8EncodedKeySpec(bytes));
        } catch (Exception e) {
            // should not occur 
            Log.w(TAG, "setPrivateKey(): " + e);
            throw new RuntimeException(e);
        } 
    } 
 
    boolean containsAnyRawData() { 
        return !mBundle.isEmpty();
    } 
 
    byte[] getData(String key) {
        return mBundle.get(key);
    }