1

I'm trying to port this JS code to Java.

I have tried using BoucyCastle without success. The output was not consistent.

var crypto = require('crypto'),
        algorithm = 'aes-256-ctr',
        password = '000000000000000000000000';

function encrypt(text) {
    var cipher = crypto.createCipher(algorithm, password)
    var crypted = cipher.update(text, 'utf8', 'hex')
    crypted += cipher.final('hex');
    return crypted;
}
var encrypted = encrypt("0")
console.log(encrypted);

Any ideas ?


EDIT: This is not a duplicate as the other question is using AES-ECB with padding.

mirch667
  • 35
  • 6
  • Possible duplicate of [Encrypt with Node.js Crypto module and decrypt with Java (in Android app)](http://stackoverflow.com/questions/7787773/encrypt-with-node-js-crypto-module-and-decrypt-with-java-in-android-app) – Artjom B. Apr 20 '16 at 10:24
  • @ArtjomB. : That one is for ECB mode. This does not seem to work with BoucyCastle CTR mode because it requires an IV. – mirch667 Apr 20 '16 at 11:31

0 Answers0