How do I write the below encryption Java code in Node.js?
-
Hi, I am moving my current application for some reason to Node.js (I like it). But moving encryption part is becoming difficult. Can anyone provide solution for this. I have tried but no luck always the encryption generated is wrong in Node.js when compared to Java. I have checked node.js crypto document but no luck. //SecretKeySpec creation code. SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); PBEKeySpec keySpec = new PBEKeySpec("myEncyptKey".toCharArray(),"myCryptSalt".getBytes(CharEncoding.UTF_8), 65536, 256); SecretKeySpec secretKeySpec = new SecretKeySpec(factory.generateSecret(keySpec).getEncoded(), "AES"); //Encryption code Cipher aes = Cipher.getInstance("AES/ECB/PKCS5Padding"); aes.init(Cipher.ENCRYPT_MODE, secretKeySpec); byte[] encrypted = aes.doFinal(plainText.getBytes(CharEncoding.UTF_8));
-
Answer:
respected, i a m not expert in java(i'm beginner) but in node.js , however i have used file encryption/encryption in node.js for my project, have a look for encrypt/decrypt file : http://www.i-visionblog.com/2014/08/file-encryptor-nodejs-module.html for string values : https://gist.github.com/csanz/1181250 This is just basics for simple encryption,if u have openssl installed you can try out other algorithm! for any errors pls let me know!
S Shiva Surya at Quora Visit the source
Related Q & A:
- How do I write a good peer review?Best solution by Quora
- How do I make a window in Java?Best solution by Stack Overflow
- How do I retrieve a URL in Java?Best solution by Stack Overflow
- How to delete a line from a .txt file in node.js?Best solution by c-sharpcorner.com
- How do I make my web browser java compatible?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.