/** * Decrypt master password * * @param pw the password to decrypt * @return the decrypted password * @throws MasterPasswordUnavailableException if decryption fails */ private static String decryptPassword(byte[] pw) throws MasterPasswordUnavailableException { assert SystemInfo.isWindows; try { return new String(WindowsCryptUtils.unprotect(pw), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("UTF-8 not available", e); } }
/** * Encrypt master password * * @param pw the password to encrypt * @return the encrypted password * @throws MasterPasswordUnavailableException if encryption fails */ private static byte[] encryptPassword(String pw) throws MasterPasswordUnavailableException { assert SystemInfo.isWindows; return WindowsCryptUtils.protect(EncryptionUtil.getUTF8Bytes(pw)); }