How can I construct a java.security.PublicKey object from a base64 encoded string? -


i have bse64encoded string public key external source (android store) , need use verify signed content. how can convert string instance of java.security.publickey interface. on java 6 if makes difference.

the key (probably) generated using standard java lib , not bouncy castle (its remote team not sure). sample code says use security.generatepublickey(base64encodedpublickey); security object in standard java has no such method.

ok grins ... try this

  • base64 decode key data byte array (byte[])
  • create new x509encodedkeyspec using byte array
  • get instance of keyfactory using keyfactory.getinstance("rsa") assuming rsa here
  • call method generatepublic(keyspec) x509encodedkeyspec
  • result /should/ public key usage.

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -