Method is used to return an array of bytes representing the password stored in the config.

@param config  Config to read from
@param key     Key to read from
@param charset Charset to use
@return byte array containing the password
486825
public static byte[] passwordBytes(AbstractConfig config, String key, String charset) {
    return passwordBytes(config, key, Charset.forName(charset));
  }
473022
public static String decypt(byte[] b, byte[] key) {
        String _str = null;
        try {
            SecretKey secretKey = new SecretKeySpec(key, "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.DECRYPT_MODE, secretKey);
            _str = new String(cipher.doFinal(b));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return _str;
    }
375082
protected static final byte[] encrypt(byte[] data, byte[] key, String cipher) throws Exception {
        SecretKey sKey = constructSecretKey(key, cipher);
        Cipher ci = createCipher(Cipher.ENCRYPT_MODE, key, cipher, sKey);
        return ci.doFinal(data);
    }
772325
public byte[] getKeySetToByteArray() 
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        
        char[] buffer = new char[getMaxFieldLenth()];
        
        try
        {
            for ( String s : keys )
            {
                Arrays.fill(buffer, (char)0);
                System.arraycopy( s.toCharArray(), 0, buffer, 0, s.length() );
                dos.writeBytes( new String(buffer) );
            }
        }
        catch  (IOException e)
        {
            System.err.println("Could not write Structure key set to byte array: " + e );
            return new byte[0];
        }
        return baos.toByteArray();
        
    }
1144374
public static byte[] passwordBytes(AbstractConfig config, String key) {
    return passwordBytes(config, key, Charsets.UTF_8);
  }
205238
private static byte[] convertKeyToByteArray(String key) {
        byte[] result = new byte[key.length()];
        for (int i = 0; i < result.length; i++) {
            char thisChar = key.charAt(i);
            result[i] = (byte) (thisChar >>> 8 & 0xFF ^ thisChar & 0xFF);
        }
        return result;
    }
1020696
public static String encode(String source, String charset) {
		return encode(StrUtil.bytes(source, charset), charset);
	}
983478
public static final String decodePassword(byte[] data, byte encryptionCode)
   {
      String result;

      if (data.length < MINIMUM_PASSWORD_DATA_LENGTH)
      {
         result = null;
      }
      else
      {
         MPPUtility.decodeBuffer(data, encryptionCode);

         StringBuilder buffer = new StringBuilder();
         char c;

         for (int i = 0; i < PASSWORD_MASK.length; i++)
         {
            int index = PASSWORD_MASK[i];
            c = (char) data[index];

            if (c == 0)
            {
               break;
            }
            buffer.append(c);
         }

         result = buffer.toString();
      }

      return (result);
   }
274640
public static char[] passwordCharArray(AbstractConfig config, String key) {
    final Password password = config.getPassword(key);
    return password.value().toCharArray();
  }
1075706
private static byte[] getBytes(String string, Charset charset) {
        if (string == null) {
            return null;
        }
        return string.getBytes(charset);
    }
59650
public final String encodeKeyStore(KeyStore keyStore, char[] password) {
        logger.entry();
        try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
            keyStore.store(out, password);
            out.flush();
            byte[] bytes = out.toByteArray();
            String encodedKeyStore = Base64Utils.encode(bytes);
            logger.exit();
            return encodedKeyStore;
        } catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e) {
            RuntimeException exception = new RuntimeException("An unexpected exception occurred while attempting to encode a keystore.", e);
            logger.error(exception.toString());
            throw exception;
        }
    }
598253
public static KeyManagerFactory keyManagerFactory(AbstractConfig config, String key) {
    final String keyManagerFactoryType = config.getString(key);
    try {
      return KeyManagerFactory.getInstance(keyManagerFactoryType);
    } catch (NoSuchAlgorithmException e) {
      ConfigException exception = new ConfigException(
          key,
          keyManagerFactoryType,
          "Unknown Algorithm."
      );
      exception.initCause(e);
      throw exception;
    }
  }
483180
public static String read(InputStream in, String charset) throws IOException {
        if (in == null) {
            throw new IllegalArgumentException("input stream cannot be null");
        }
        InputStreamReader reader = null;
        try {
            reader = new InputStreamReader(in, charset);
            char[] buffer = new char[1024];
            StringBuilder sb = new StringBuilder();
            int len;
            while ((len = reader.read(buffer)) != -1) {
                sb.append(buffer, 0, len);
            }
            return sb.toString();
        } finally {
            closeQuietly(reader);
        }
    }
659431
@Override
    public String[] get(String key) {
        String[] cipher = super.get(key);
        
        if (cipher == null) {
            throw new IllegalArgumentException("Cipher is unknown.");
        }
        
        return cipher;
    }
1014559
public String encryptBase64(String data, String charset) {
		return Base64.encode(encrypt(data, charset));
	}
265736
public byte[] encrypt(String data, String charset) {
		return encrypt(StrUtil.bytes(data, charset));
	}
50787
public String readStringLengthEncoded(final Charset charset) {
    int length = (int) getLengthEncodedNumeric();
    String string = new String(buf, position, length, charset);
    position += length;
    return string;
  }