Back to project page PasswordDroid.
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.
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; } }