CryptTool { public static byte[] randomNonce() { byte[] nonce = new byte[NaCl.NONCEBYTES]; random.nextBytes(nonce); return nonce; }  static EncryptResult encryptTextMessage(String text, byte[] senderPrivateKey, byte[] recipientPublicKey); static EncryptResult encryptImageMessage(EncryptResult encryptResult, UploadResult uploadResult, byte[] senderPrivateKey, byte[] recipientPublicKey); static EncryptResult encryptFileMessage(EncryptResult encryptResult,
	                                               UploadResult uploadResult,
	                                               String mimeType,
	                                               String fileName,
	                                               int fileSize,
	                                               UploadResult uploadResultThumbnail,
	                                               byte[] senderPrivateKey, byte[] recipientPublicKey); static byte[] decrypt(byte[] box, byte[] privateKey, byte[] publicKey, byte[] nonce); static byte[] decryptFileData(byte[] fileData, byte[] secret); static byte[] decryptFileThumbnailData(byte[] fileData, byte[] secret); static ThreemaMessage decryptMessage(byte[] box,  byte[] recipientPrivateKey, byte[] senderPublicKey, byte[] nonce); static void generateKeyPair(byte[] privateKey, byte[] publicKey); static EncryptResult encrypt(byte[] data,byte[] privateKey, byte[] publicKey); static EncryptResult encryptFileData(byte[] data); static EncryptResult encryptFileThumbnailData(byte[] data, byte[] encryptionKey); static byte[] hashEmail(String email); static byte[] hashPhoneNo(String phoneNo); static byte[] randomNonce(); static byte[] derivePublicKey(byte[] privateKey);  }
@Test public void testRandomNonce() throws Exception { byte[] randomNonce = CryptTool.randomNonce(); Assert.assertNotNull("random nonce", randomNonce); Assert.assertSame("nonce length", randomNonce.length, NaCl.NONCEBYTES); }