Here you can find the source of getKeyString(Key key)
public static String getKeyString(Key key)
//package com.java2s; //License from project: Apache License import java.security.Key; import sun.misc.BASE64Encoder; public class Main { public static String getKeyString(Key key) { byte[] keyBytes = key.getEncoded(); String s = (new BASE64Encoder()).encode(keyBytes); // String s=null; // try { // s = new String(Base64.getDecoder().decode(keyBytes), "utf-8"); // } catch (UnsupportedEncodingException e) { // e.printStackTrace(); // } return s; }//from w ww . j av a2 s. co m }