Package org.keyczar

Examples of org.keyczar.Encrypter.encrypt()


            plaintext = b.build().toByteArray();
        }

        Encrypter publicKeyEncrypter = getPublicKeyEncrypter(user.getPublicKey());
        byte[] ciphertext = publicKeyEncrypter.encrypt(plaintext);

        SecretData.Builder s = SecretData.newBuilder();
        s.setCiphertext(ByteString.copyFrom(ciphertext));
        s.setEncryptedWith(EncryptedWith.PUBLIC_KEY);
        s.setVersion(1);
View Full Code Here


        b.setVersion(1);

        byte[] serialized = KeyczarUtils.pack(secret.cryptoKey);
        byte[] ciphertext;
        try {
            ciphertext = encrypter.encrypt(serialized);
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error encrypting key", e);
        }

        b.setCiphertext(ByteString.copyFrom(ciphertext));
View Full Code Here

        b.setVersion(1);

        byte[] serialized = KeyczarUtils.pack(secret.cryptoKey);
        byte[] ciphertext;
        try {
            ciphertext = encrypter.encrypt(serialized);
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error encrypting key", e);
        }

        b.setCiphertext(ByteString.copyFrom(ciphertext));
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.