@Test public void encrypt() throws Exception { final byte[] salt = "some salt for the server private".getBytes(); final byte[] key = CryptoUtil.secretKey("key", salt); final String encrypted = CryptoUtil.encrypt(key, "some string to encrypt"); assertThat(encrypted, is(notNullValue())); }
public static String encrypt(final byte[] key, final String content) throws Exception { final byte[] iv = BlockCipher.getIV(); final byte[] encrypted = new CryptoBox(key).encrypt(iv, content.getBytes(ASCII)); final String base64 = new UrlBase64().encode(prependIV(encrypted, iv)); return URLEncoder.encode(base64, ASCII.displayName()); }
CryptoUtil { public static String encrypt(final byte[] key, final String content) throws Exception { final byte[] iv = BlockCipher.getIV(); final byte[] encrypted = new CryptoBox(key).encrypt(iv, content.getBytes(ASCII)); final String base64 = new UrlBase64().encode(prependIV(encrypted, iv)); return URLEncoder.encode(base64, ASCII.displayName()); } }
CryptoUtil { public static String encrypt(final byte[] key, final String content) throws Exception { final byte[] iv = BlockCipher.getIV(); final byte[] encrypted = new CryptoBox(key).encrypt(iv, content.getBytes(ASCII)); final String base64 = new UrlBase64().encode(prependIV(encrypted, iv)); return URLEncoder.encode(base64, ASCII.displayName()); } private  CryptoUtil(); }
CryptoUtil { public static String encrypt(final byte[] key, final String content) throws Exception { final byte[] iv = BlockCipher.getIV(); final byte[] encrypted = new CryptoBox(key).encrypt(iv, content.getBytes(ASCII)); final String base64 = new UrlBase64().encode(prependIV(encrypted, iv)); return URLEncoder.encode(base64, ASCII.displayName()); } private  CryptoUtil(); static String encrypt(final byte[] key, final String content); static String decrypt(final byte[] key, final String content); static byte[] secretKey(final String password, final byte[] salt); static String endpointToken(final String uaid, final String channelId, final byte[] key); }
CryptoUtil { public static String encrypt(final byte[] key, final String content) throws Exception { final byte[] iv = BlockCipher.getIV(); final byte[] encrypted = new CryptoBox(key).encrypt(iv, content.getBytes(ASCII)); final String base64 = new UrlBase64().encode(prependIV(encrypted, iv)); return URLEncoder.encode(base64, ASCII.displayName()); } private  CryptoUtil(); static String encrypt(final byte[] key, final String content); static String decrypt(final byte[] key, final String content); static byte[] secretKey(final String password, final byte[] salt); static String endpointToken(final String uaid, final String channelId, final byte[] key);  }