List of usage examples for javax.crypto ShortBufferException printStackTrace
public void printStackTrace()
From source file:net.networksaremadeofstring.cyllell.Authentication.java
private String SignHeaders(String dataToSign) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException, NoSuchProviderException { PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(Base64.decode(this.PrivateKey.getBytes(), 0)); KeyFactory kf = KeyFactory.getInstance("RSA"); PrivateKey pk = kf.generatePrivate(spec); Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING"); cipher.init(Cipher.ENCRYPT_MODE, pk); byte[] EncryptedStream = new byte[cipher.getOutputSize(dataToSign.length())]; try {/*from w w w . j a va2 s .c o m*/ cipher.doFinal(dataToSign.getBytes(), 0, dataToSign.length(), EncryptedStream, 0); } catch (ShortBufferException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Base64.encodeToString(EncryptedStream, Base64.NO_WRAP); }