title: java.security.UnrecoverableKeyException: Cannot recover key when executing KeyManagerFactory.init()
body: <p>I have the following code that tries to initialize KeyManagerFactory using SHA-256 hash as password.</p>
  
  <pre><code>public static KeyManager[] getKeystoreManagers()
      throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, NoSuchProviderException {
      KeyStore keystore = getKeyStore();
  
      if (keystore == null) {
          return null;
      }
  
      KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());        
      kmf.init(keystore, getMachinePassword(SHA_256).toCharArray());
  
      return kmf.getKeyManagers();
  }
  </code></pre>
  
  <p>getKeyStore() returns my application keystore. getMachinePassword() returns a password using SHA-256, 64 digits password length.<br> The problem is that I get the exception when init() is called:</p>
  
  <pre><code>java.security.UnrecoverableKeyException: Cannot recover key
  </code></pre>
  
  <p>If I am passing smaller password length lets say, 50 digits the init succeeded. <br> What seems to be the problem here? </p>