/** * Writes some bytes in Hexadecimal format * * @param bytes Bytes to format * @return Hex string */ public static String toHexString(byte[] bytes) { return toHexString(bytes, 0, bytes.length); }
public FileConfidentialStore(File rootDir) throws IOException { this.rootDir = rootDir; LoggerFactory.getLogger(FileConfidentialStore.class).info( "[key-store] Using file based key store at {}", rootDir.getAbsolutePath() ); File masterSecret = new File(rootDir, "master.key"); if (!masterSecret.exists()) { // we are only going to use small number of bits (since export control limits AES key length) // but let's generate a long enough key anyway FileUtils.write(masterSecret, Utils.toHexString(randomBytes(128)), ENCODING); } this.masterKey = SecurityUtils.toAes128Key(FileUtils.readFileToString(masterSecret, ENCODING)); }