Android Open Source - PasswordDroid Util






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.crypto;
//  ww w  .j a  va  2 s . com
/* 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/. */

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

public class Util {

    public static void addAllBytesToList(byte[] toadd, List<Byte> list) {
        for (byte i : toadd) {
            list.add(i);
        }
    }

    public static List<Byte> byteArrayToList(byte[] toadd) {
        List<Byte> result = new ArrayList<>(toadd.length);
        addAllBytesToList(toadd, result);
        return result;
    }

    public static byte[] byteListToArray(List<Byte> toadd) {
        byte[] result = new byte[toadd.size()];
        for (int i = 0; i < result.length; i++) {
            result[i] = toadd.get(i);
        }
        return result;
    }

    public static String byteListToString(List<Byte> list) {
        String result = "";

        for (byte i : list) {
            result += String.format("%02x", ((int) i) & 0xFF);
        }

        return result;
    }

    public static List<Byte> stringListToUtf8ByteList(List<String> list) throws UnsupportedEncodingException {
        List<Byte> result = new ArrayList<>();

        for (String i : list) {
            for (byte j : i.getBytes("UTF-8")) {
                result.add(j);
            }
        }

        return result;
    }

    public static byte[] intToByteArray(int i) {
        return ByteBuffer.allocate(4).putInt(i).array();
    }

    public static <T> List<T> cloneList(List<T> list) {
        List<T> result = new ArrayList<>(list.size());
        result.addAll(list);
        return result;
    }

}




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