[aerogear-dev] Aerogear in Java and Creating Cyptobox using PublicKey

niteshdev niteshglass at gmail.com
Fri Sep 9 06:59:42 EDT 2016


Hi There, 

We are integrating aerogear java library in our java backend. 

We have list of users public key in base64 string. Now when I want to send a
encrypted message to our users. 

When we are trying to create a instance of CryptoBox then at that time we
need to provide a instance of PublicKey. How do we create a publickey
Instance from a base64 string or raw bytes. 

CryptoBox pandora = new CryptoBox(myprivatekey, userspublickey);

For the normal RSA i found this snippet over internet but i am assuming that
this has to be different for Aerogear. 
public static PublicKey loadPublicKey(String stored) throws
GeneralSecurityException {
		byte[] data = Base64.decode(stored.toCharArray());
		X509EncodedKeySpec spec = new X509EncodedKeySpec(data);
		KeyFactory fact = KeyFactory.getInstance("RSA");
		return fact.generatePublic(spec);
	}

Any help in this regard is highly appreciated. 

Many Thanks,
Nitesh



--
View this message in context: http://aerogear-dev.1069024.n5.nabble.com/Aerogear-in-Java-and-Creating-Cyptobox-using-PublicKey-tp12755.html
Sent from the aerogear-dev mailing list archive at Nabble.com.


More information about the aerogear-dev mailing list