List of usage examples for org.bouncycastle.crypto CryptoException CryptoException
public CryptoException(String message, Throwable cause)
From source file:at.asitplus.regkassen.common.util.CryptoUtil.java
License:Apache License
/** * get hash value for given String/*from w w w . ja v a 2s. com*/ * @param data string to be hashed * @return hash value as biginteger in hex representation * @throws CryptoException */ public static String hashData(final String data) throws CryptoException { try { final MessageDigest md = MessageDigest.getInstance("SHA-256", "BC"); md.update(data.getBytes("UTF-8")); return new BigInteger(md.digest()).toString(16); } catch (final Exception e) { throw new CryptoException(e.getMessage(), e); } }
From source file:com.distrimind.util.crypto.Agreement.java
License:Open Source License
public void receiveData(byte[] data) throws CryptoException { try {//from w w w.j a v a 2 s. c o m if (hasFinishedReceiption()) throw new IllegalAccessException("The process has finished"); receiveData(actualStepForReception++, data); } catch (Exception e) { if (e instanceof CryptoException) throw (CryptoException) e; else throw new CryptoException("", e); } }