Here you can find the source of getPublicKeyFromBytes(final String algorithm, final byte[] publicKeyBytes)
private static PublicKey getPublicKeyFromBytes(final String algorithm, final byte[] publicKeyBytes)
//package com.java2s; /**/*w w w. j a va2s . com*/ * Copyright (C) 2010-2016 Structr GmbH * * This file is part of Structr <http://structr.org>. * * Structr is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Structr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Structr. If not, see <http://www.gnu.org/licenses/>. */ import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec.X509EncodedKeySpec; public class Main { private static PublicKey getPublicKeyFromBytes(final String algorithm, final byte[] publicKeyBytes) { try { final KeyFactory keyFactory = KeyFactory.getInstance(algorithm); final X509EncodedKeySpec spec = new X509EncodedKeySpec(publicKeyBytes); return keyFactory.generatePublic(spec); } catch (Throwable t) { t.printStackTrace(); } return null; } }