public static byte[] decodeBase64Content(byte[] content) { return decodeBase64Content(content, false); }
Crypto(String key) { this.binaryKey = Helpers.decodeBase64Content(key.getBytes()); }
@Override public void characters(char[] ch, int start, int length) throws SAXException { String content = new String(ch, start, length); if (protectedContent) { content = new String(memoryProtection.decrypt(Helpers.decodeBase64Content(content.getBytes(), false))); } System.out.print(content); protectedContent = false; }
@Nullable static byte[] getBinaryElementContent(String elementPath, Element parentElement) { Element result = getElement(elementPath, parentElement, false); if (result == null) { return null; } String id = result.getAttribute("Ref"); Element content = getElement("//Binaries/Binary[@ID=" + id + "]", parentElement.getOwnerDocument().getDocumentElement(),false); if (content == null) { throw new IllegalStateException("Could not find binary content with ID " + id); } return Helpers.decodeBase64Content(content.getTextContent().getBytes(), content.hasAttribute("Compressed")); }
/** * Return true if the Nonce and the Verifier on a message match * * @param verifiable a message containing those fields */ boolean verify(Message.Verifiable verifiable) { if (getKey() == null || verifiable.Verifier == null || verifiable.Nonce == null || verifiable.Verifier.equals("") || verifiable.Nonce.equals("")) { return false; } // The nonce is base64 encoded version of an iv byte[] iv = Helpers.decodeBase64Content(verifiable.Nonce.getBytes(), false); // The verifier is the base64 encoded encrypted version of the nonce String decrypted = decryptFromBase64(verifiable.Verifier, iv); // the decrypted verifier should be the same as the nonce return decrypted.equals(verifiable.Nonce); }
@Override public KeePassFile.ByteArray read(InputNode inputNode) throws Exception { String input = inputNode.getValue(); byte[] value = input == null? new byte[0] : input.getBytes(); return new KeePassFile.ByteArray(Helpers.decodeBase64Content(value, false)); }
public XMLEvent transform (XMLEvent event) { switch (event.getEventType()) { case START_ELEMENT: { Attribute attribute = event.asStartElement().getAttributeByName(new QName("Protected")); if (attribute != null) { decryptContent = Helpers.toBoolean(attribute.getValue()); } break; } case END_ELEMENT: { decryptContent = false; break; } case CHARACTERS: { if (decryptContent) { String text = event.asCharacters().getData(); text = new String(streamEncryptor.decrypt(Helpers.decodeBase64Content(text.getBytes(), false))); event = xmlEventFactory.createCharacters(text); } break; } } return event; } }
byte[] bytes; if (base64in) { bytes = Helpers.decodeBase64Content(input.getBytes(), false); } else { bytes = input.getBytes();
@Override public byte[] getBinaryProperty(String s) { BinaryProperty bp = getBinaryProp(s, binary); if (bp == null) { return null; } KeePassFile.Binaries.Binary binary = null; for (KeePassFile.Binaries.Binary b : database.getBinaries()) { if (b.getId().equals(Integer.valueOf(getBinaryContent(bp)))) { binary = b; } } if (binary == null) { return null; } return Helpers.decodeBase64Content(binary.getValue().getBytes(), binary.getCompressed()); }
crypto.setKey(Helpers.decodeBase64Content(request1.Key.getBytes(), false));
boolean verify(Message.Request request) { if (!verify((Message.Verifiable) request)) { return false; } byte[] iv = Helpers.decodeBase64Content(request.Nonce.getBytes(), false); // decrypt all the fields if (request.Login != null) { request.Login = decryptFromBase64(request.Login, iv); } if (request.Password != null) { request.Password = decryptFromBase64(request.Password, iv); } if (request.Url != null) { request.Url = decryptFromBase64(request.Url, iv); } if (request.SubmitUrl != null) { request.SubmitUrl = decryptFromBase64(request.SubmitUrl, iv); } if (request.Uuid != null) { request.Uuid = decryptFromBase64(request.Uuid, iv); } return true; }