Here you can find the source of toByteArray(String s)
public static byte[] toByteArray(String s)
//package com.java2s; /******************************************************************************* * PswGen - Manages your websites and repeatably generates passwords for them * PswGenDroid - Generates your passwords managed by PswGen on your mobile * * Copyright (C) 2005-2016 Uwe Damken * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.// ww w. ja va 2s.c om *******************************************************************************/ public class Main { /** * Konvertiert einen Hex-String mit zwei Hex-Zeichen je Byte in ein Byte-Array. */ public static byte[] toByteArray(String s) { byte[] ba = new byte[s.length() / 2]; for (int i = 0; i < ba.length; i++) { ba[i] = toByte(s.substring(2 * i, 2 * i + 2)); } return ba; } public static byte toByte(String s) { return (Integer.valueOf(Integer.parseInt(s, 16))).byteValue(); } }