Porting Node 'crypto' code to Java

微笑、不失礼 提交于 2019-12-11 13:32:59

问题


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.

来源:https://stackoverflow.com/questions/36740355/porting-node-crypto-code-to-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!