KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to allow Alice to create a public/private key pair so that Bob can send her confidential messages. However, I want Alice to be able to check her messages from anywhere, and it would be a pain for her to have to carry around a memory stick containing her private key. Is there some way that Alice can create a public/private key pair based on a password which she remembers? In this way she could simply generate the private key (and public key) whenever she wanted to. The short version of this question is: Where can I find the Java equivalent of cryptico.js . Also, here's the same question on Stack Overflow, but for javascript. Edit: Here's my first attempt at a solution: SecureRandom saltRand = new SecureRandom(new byte[] { 1, 2, 3, 4 }); byte[] salt = new byte[16]; saltRand.nextBytes(salt); int keyLength = 3248; SecretKeyFactory factory = SecretKeyFactory .getInstance("PBKDF2WithHmacSHA1"); KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 8192, keyLength); SecretKey key = factory.generateSecret(spec); SecureRandom keyGenRand = SecureRandom.getInstance("SHA1PRNG"); keyGenRand.setSeed(key.getEncoded()); KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); gen.initialize(keyLength, keyGenRand); java.security.KeyPair p = gen.generateKeyPair();
Tags (comma-separated)
Save Edits
Cancel