3

I'm working on Twofish encryption and worked on something like the code below.
However, I have been getting the above stated error.
Kindly help look into it and advice as necessary.

SecureRandom sr= new SecureRandom(cipher_key.getBytes());
      KeyGenerator kg=KeyGenerator.getInstance("twofish");
      kg.init(sr);
      SecretKey sk = kg.generateKey();
      // create an instance of cipher
        Cipher cipher = Cipher.getInstance("twofish");

        // initialize the cipher with the key
        cipher.init(Cipher.ENCRYPT_MODE, sk);

        // enctypt!
        encrypted = cipher.doFinal(word.getBytes());
Moresky
  • 77
  • 4
  • Please state the *exact* exception you're receiving. Is it a NoSuchAlgorithmException, for example? – ben3000 Jul 30 '16 at 03:57
  • Apologies, the error is "Exception in thread "main" java.security.NosuchAlgorithnException:Twofish KeyGenerator not available".. – Moresky Jul 30 '16 at 07:25

0 Answers0