Package com.im.imjutil.exception

Examples of com.im.imjutil.exception.CipherException


      messageDigest.reset();
      messageDigest.update(value);
      return messageDigest.digest();
     
    } catch (Exception e) {
      throw new CipherException(Convert.toString(
          "Erro ao codificar, causa [", e.getClass().getSimpleName(),
          " - ", e.getMessage(), "]"), e);
    }
  }
View Full Code Here


    }
  }

  @Override
  public byte[] decrypt(byte[] value) throws CipherException {
    throw new CipherException(Convert.toString(
        "Operacao nao suportada pelo algoritmo [", type.cipher, "]"));
  }
View Full Code Here

class Base64Cipher extends Cipher {

  @Override
  public byte[] encrypt(byte[] value) throws CipherException {
    if (value == null || value.length == 0) {
      throw new CipherException("Byte array nulo ou invalido");
    }
    return Base64.encode(value).getBytes();
  }
View Full Code Here

  }

  @Override
  public byte[] decrypt(byte[] value) throws CipherException {
    if (value == null || value.length == 0) {
      throw new CipherException("Byte array nulo ou invalido");
    }
    return Base64.decode(new String(value));
  }
View Full Code Here

      initialize();
      cipherAlgorithm.init(javax.crypto.Cipher.ENCRYPT_MODE, secretKey);
      return cipherAlgorithm.doFinal(value);
     
    } catch (Exception e) {
      throw new CipherException(Convert.toString(
          "Cipher error: ", e.getMessage()), e);
    }
  }
View Full Code Here

      initialize();
      cipherAlgorithm.init(javax.crypto.Cipher.DECRYPT_MODE, secretKey);
      return cipherAlgorithm.doFinal(value);
     
    } catch (Exception e) {
      throw new CipherException(Convert.toString(
          "Cipher error: ", e.getMessage()), e);
    }
  }
View Full Code Here

TOP

Related Classes of com.im.imjutil.exception.CipherException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.