Allora ho trovato che per criptare la chiave è molto semplice, è sufficiente usare il metodo seguente
e successivamente eseguire l'unwrap cosìcodice:DESkeySpec = new DESkeySpec("blahblahblah"); SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); SecretKey passwordKey = kf.generateSecret(keySpec); Cipher c = Cipher.getInstance("DES"); c.init(Cipher.WRAP_MODE, passwordKey); byte[] wrappedKey = c.wrap(sharedKey);
codice:c = Cipher.getInstance("DES"); c.init(Cipher.UNWRAP_MODE, passwordKey); Key unwrappedKey = c.unwrap(wrappedKey, "DES", Cipher.SECRET_KEY);Molto semplice
Spero possa servire a qualcuno.
Ciauz




Rispondi quotando