Here you can find the source of generateKeyFromString(final String secKey, String algorithm)
public static Key generateKeyFromString(final String secKey, String algorithm) throws Exception
//package com.java2s; //License from project: Apache License import java.security.Key; import java.util.Base64; import javax.crypto.spec.SecretKeySpec; public class Main { public static Key generateKeyFromString(final String secKey, String algorithm) throws Exception { final byte[] keyVal = Base64.getDecoder().decode(secKey.getBytes()); final Key key = new SecretKeySpec(keyVal, algorithm); return key; }/*from www .j av a 2 s . co m*/ public static Key generateKeyFromString(final byte[] secKey, String algorithm) throws Exception { final Key key = new SecretKeySpec(secKey, algorithm); return key; } }