Skip to content

Instantly share code, notes, and snippets.

View ligerzero459's full-sized avatar

Ryan Mottley ligerzero459

View GitHub Profile
@ligerzero459
ligerzero459 / Java.java
Last active August 29, 2015 14:27 — forked from kennydude/Java.java
Encrypt from Java and decrypt on Node.js
// Encrypt where jo is input, and query is output and ENCRPYTION_KEy is key
byte[] input = jo.toString().getBytes("utf-8");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(ENCRYPTION_KEY.getBytes("UTF-8"));
SecretKeySpec skc = new SecretKeySpec(thedigest, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skc);
byte[] cipherText = new byte[cipher.getOutputSize(input.length)];