Here you can find the source of toByteArrayForPBE(char[] chars)
Parameter | Description |
---|---|
chars | the char array |
public static byte[] toByteArrayForPBE(char[] chars)
//package com.java2s; public class Main { /**/*from ww w . j av a 2s .co m*/ * Convert the given char array into a * byte array for use with PBE encryption. * * @param chars the char array * @return the converted array */ public static byte[] toByteArrayForPBE(char[] chars) { byte[] out = new byte[chars.length]; for (int i = 0; i < chars.length; i++) { out[i] = (byte) chars[i]; } int length = out.length * 2; byte[] ret = new byte[length + 2]; int j = 0; for (int i = 0; i < out.length; i++) { j = i * 2; ret[j] = 0; ret[j + 1] = out[i]; } ret[length] = 0; ret[length + 1] = 0; return ret; } }