@ Override public void store ( String key , byte [ ] payload ) throws IOException { try { Cipher sym = Cipher . getInstance ( "AES" ) ; sym . init ( Cipher . ENCRYPT_MODE , masterKey ) ; try ( FileOutputStream fos = new FileOutputStream ( getFileFor ( key ) ) ; CipherOutputStream cos = new CipherOutputStream ( fos , sym ) ) { cos . write ( payload ) ; cos . write ( MAGIC ) ; } } catch ( GeneralSecurityException e ) { throw new IOException ( "Failed to persist the key: " + key , e ) ; } }
Persists the payload of a key to the disk .