GooglePlayBillingSecurity { public static PrivateKey createPrivateKey(String privateKey64) { try { final byte[] decodedKey = Base64.decode(privateKey64, Base64.DEFAULT); final KeyFactory keyFactory = KeyFactory.getInstance(KEY_TYPE); return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(decodedKey)); } catch (InvalidKeySpecException e) { throw new IllegalStateException(e); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }  static PublicKey createPublicKey(String publicKey64); static PrivateKey createPrivateKey(String privateKey64); static String sign(String privateKey64, String data); static String sign(PrivateKey privateKey, String data); static boolean verifySignature(String publicKey64, String signedData, String signature64); static boolean verifySignature(PublicKey publicKey, String signedData, String signature64);  }
@Test public void testPrivateKeyInValidFormat() { GooglePlayBillingSecurity.createPrivateKey(TEST_PRIVATE_KEY); }