Git Product home page Git Product logo

aes-example's Issues

Javascript and Java not compatible

Java Code:

String key = "abcdefghijklmop";
String clean = "helloworld";
String salt = AesUtil.random(16);
String iv = AesUtil.random(16);

System.out.println("Salt: " + salt);
System.out.println("IV: " + iv);

AesUtil aes = new AesUtil(128, 1000);
String encrypt = aes.encrypt(salt, iv, key, clean);
System.out.println("Encrypt: " + encrypt);
String decrypt = aes.decrypt(salt, iv, key, encrypt);
System.out.println("Decrypt: " + decrypt);

Java output: (Random newline after encrypt...)

Salt: 0d79ffd760b780829c871867a26443c1
IV: 261a6cc58ec82bf7bce99b424e0458dc
� T��ƹ&�[���?5 //KEY OUTPUT ADDED TO ENCRYPTION METHOD new String(key, "UTF-8")
Encrypt: dlRWkbQdSn8WxP9qNO/g9A==

Decrypt: helloworld

Javascript Code:

var salt = "0d79ffd760b780829c871867a26443c1"
var iv = "261a6cc58ec82bf7bce99b424e0458dc"
var pass = "abcdefghijklmop"
var encode = "dlRWkbQdSn8WxP9qNO/g9A=="

var aesUtil = new AesUtil(128, 1000);
var plain = aesUtil.encrypt(salt, iv, pass, encode);
console.log(plain)

I replaced the CryptoJS.enc.Hex.parse(salt) to salt and same with iv because I dont want hex from hex...
So it should work, should'nt it?

Output:

0eEEBBiU0g0wvrhQvvwS3z9CeYMHdLee5gu5vMcXlP0=

Does not work for me, did I any mistakes? Can you help me?

256-bit version

It would be great to have a 256-bit version as well, thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.