Android Open Source - PasswordDroid File Format






From Project

Back to project page PasswordDroid.

License

The source code is released under:

GNU General Public License

If you think the Android project PasswordDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.wuthoehle.passworddroid.service.model;/* Copyright (c) 2015 Marco Huenseler <marcoh.huenseler+git@gmail.com>
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*from w w w. ja v  a 2  s.  com*/
import android.util.Log;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.Queue;

public class FileFormat {
    public static final byte ID_DATABASE = 0;
    public static final byte ID_CATEGORY = 1;
    public static final byte ID_ENTRY = 2;
    public static final byte ID_COUNTABLE = 3;
    public static final byte ID_CUSTOMIZABLE = 4;
    public static final byte ID_COMMENTABLE = 5;
    public static final byte ID_SALTABLE = 6;

    public static byte getByte(Queue<Byte> bytestream) throws FileFormat.MalformedDatabaseFileException {
        byte result = 0;

        if (bytestream.size() == 0) {
            throw new FileFormat.MalformedDatabaseFileException("No byte left in queue!");
        }

        return bytestream.remove();
    }

    public static int getInteger(Queue<Byte> bytestream) throws FileFormat.MalformedDatabaseFileException {
        int result = 0;
        byte[] read = new byte[4];

        if (bytestream.size() < 4) {
            throw new FileFormat.MalformedDatabaseFileException("No integer left in queue!");
        }

        for (int i = 0; i < 4; i++) {
            read[i] = bytestream.remove();
        }
        result = ByteBuffer.wrap(read).getInt();

        return result;
    }

    public static String getString(Queue<Byte> bytestream, int size) throws FileFormat.MalformedDatabaseFileException {
        String result = "";
        byte[] read_string = new byte[size];

        if (bytestream.size() < size) {
            throw new FileFormat.MalformedDatabaseFileException("No string left in queue!");
        }

        for (int i = 0; i < size; i++) {
            read_string[i] = bytestream.remove();
        }

        if (read_string.length >= 0) {
            try {
                result = new String(read_string, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                Log.d("Entry Factory", "Unable to parse string!");
                e.printStackTrace();
            }
        }

        return result;
    }

    public static class MalformedDatabaseFileException extends IllegalArgumentException {
        public MalformedDatabaseFileException() {
        }

        public MalformedDatabaseFileException(String detailMessage) {
            super(detailMessage);
        }

        public MalformedDatabaseFileException(String message, Throwable cause) {
            super(message, cause);
        }

        public MalformedDatabaseFileException(Throwable cause) {
            super(cause);
        }
    }
}




Java Source Code List

com.lambdaworks.crypto.PBKDF.java
com.lambdaworks.crypto.SCrypt.java
de.wuthoehle.passworddroid.ApplicationTest.java
de.wuthoehle.passworddroid.PasswordDerivateActivity.java
de.wuthoehle.passworddroid.crypto.AESprng.java
de.wuthoehle.passworddroid.crypto.DerivationRunnableFactory.java
de.wuthoehle.passworddroid.crypto.Util.java
de.wuthoehle.passworddroid.crypto.SCryptParameters.SCryptParametersFactory.java
de.wuthoehle.passworddroid.crypto.SCryptParameters.SCryptParameters.java
de.wuthoehle.passworddroid.service.PasswordDroidService.java
de.wuthoehle.passworddroid.service.model.Category.java
de.wuthoehle.passworddroid.service.model.Container.java
de.wuthoehle.passworddroid.service.model.Database.java
de.wuthoehle.passworddroid.service.model.DerivatorCategory.java
de.wuthoehle.passworddroid.service.model.DerivatorDatabase.java
de.wuthoehle.passworddroid.service.model.FileFormat.java
de.wuthoehle.passworddroid.service.model.entries.Commentable.java
de.wuthoehle.passworddroid.service.model.entries.Countable.java
de.wuthoehle.passworddroid.service.model.entries.Customizable.java
de.wuthoehle.passworddroid.service.model.entries.DerivatorEntry.java
de.wuthoehle.passworddroid.service.model.entries.EntryElement.java
de.wuthoehle.passworddroid.service.model.entries.EntryFactory.java
de.wuthoehle.passworddroid.service.model.entries.EntryVisitor.java
de.wuthoehle.passworddroid.service.model.entries.Entry.java
de.wuthoehle.passworddroid.service.model.entries.GetBundleVisitor.java
de.wuthoehle.passworddroid.service.model.entries.SaltVisitor.java
de.wuthoehle.passworddroid.service.model.entries.Saltable.java
de.wuthoehle.passworddroid.service.model.entries.WriteVisitor.java