Package org.keyczar

Examples of org.keyczar.Crypter.encrypt()


        }

        Crypter crypter = secretImpl.getCrypter();
        byte[] ciphertext;
        try {
            ciphertext = crypter.encrypt(data);
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error encrypting secret", e);
        }
        item.setCiphertext(ByteString.copyFrom(ciphertext));
View Full Code Here


    public SecretData encrypt(BackendSecretData data) {
        try {
            Crypter crypter = sharedKeystore.buildCrypter(KEY);

            byte[] ciphertext = crypter.encrypt(data.toByteArray());
            SecretData.Builder secretData = SecretData.newBuilder();
            secretData.setCiphertext(ByteString.copyFrom(ciphertext));

            return secretData.build();
        } catch (Exception e) {
View Full Code Here

    public SecretData encrypt(HostGroupSecretData data) {
        try {
            Crypter crypter = sharedKeystore.buildCrypter(KEY);

            byte[] ciphertext = crypter.encrypt(data.toByteArray());
            SecretData.Builder secretData = SecretData.newBuilder();
            secretData.setCiphertext(ByteString.copyFrom(ciphertext));

            return secretData.build();
        } catch (Exception e) {
View Full Code Here

    }

    byte[] encrypt(byte[] plaintext) {
        try {
            Crypter crypter = getCrypter();
            return crypter.encrypt(plaintext);
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error encrypting data", e);
        }
    }
View Full Code Here

      throws KeyczarException {
    if (generateParams.get("class").equals("crypter")) {
      Crypter crypter = new Crypter(
          getReader(algorithm, generateParams.get("cryptedKeySet"), generateParams.get("pubKey")));
      if (generateParams.get("encoding").equals("encoded")) {
        String ciphertext = crypter.encrypt(testData);
        return ciphertext.getBytes();
      } else if (generateParams.get("encoding").equals("unencoded")) {
        byte[] ciphertext = crypter.encrypt(testData.getBytes());
        return ciphertext;
      } else {
View Full Code Here

          getReader(algorithm, generateParams.get("cryptedKeySet"), generateParams.get("pubKey")));
      if (generateParams.get("encoding").equals("encoded")) {
        String ciphertext = crypter.encrypt(testData);
        return ciphertext.getBytes();
      } else if (generateParams.get("encoding").equals("unencoded")) {
        byte[] ciphertext = crypter.encrypt(testData.getBytes());
        return ciphertext;
      } else {
        throw new KeyczarException("Expects encoded or unencoded in parameters");
      }
    } else if (generateParams.get("class").equals("encrypter")) {
View Full Code Here

      }
    } else if (generateParams.get("class").equals("encrypter")) {
      Encrypter crypter = new Encrypter(
          getReader(algorithm, generateParams.get("cryptedKeySet"), generateParams.get("pubKey")));
      if (generateParams.get("encoding").equals("encoded")) {
        String ciphertext = crypter.encrypt(testData);
        return ciphertext.getBytes();
      } else if (generateParams.get("encoding").equals("unencoded")) {
        byte[] ciphertext = crypter.encrypt(testData.getBytes());
        return ciphertext;
      } else {
View Full Code Here

          getReader(algorithm, generateParams.get("cryptedKeySet"), generateParams.get("pubKey")));
      if (generateParams.get("encoding").equals("encoded")) {
        String ciphertext = crypter.encrypt(testData);
        return ciphertext.getBytes();
      } else if (generateParams.get("encoding").equals("unencoded")) {
        byte[] ciphertext = crypter.encrypt(testData.getBytes());
        return ciphertext;
      } else {
        throw new KeyczarException("Expects encoded or unencoded in parameters");
      }
    } else {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.