javax.crypto

Javascript/NodeJS equivalent code for the Java code Cipher.doFinal(byte[])?

安稳与你 提交于 2019-12-03 20:29:34
I am migrating some server-side Java code to a new NodeJS server. I am looking for an equivalent method call in Javascript to Java's Cipher.doFinal(byte[]) Note that I can't use NodeJS Buffers because they don't support negative Byte values. So to do my encryption, I'll need a method that accepts an array of positive and negative numbers. Here's all of what I currently have that is related to this problem: Node JS / Javascript: var crypto = require('crypto'); var cipher = crypto.createCipher('aes256',key); Java (javax.crypto.Cipher): Cipher cipher; SecretKeySpec skeySpec = new SecretKeySpec

Encrypt using OpenSSL in the same way Java does

大兔子大兔子 提交于 2019-12-03 09:12:52
I have to encrypt an string using bash script in the same way I encrypt using javax.crypto.Cipher. At java I use AES-256 with the key "0123456789". But When I use openssl I had to convert "0123456789" to hex, but the result is not the same of the java echo "lun01" | openssl aes-256-cbc -e -a -K 7573746f726530313233343536373839 -iv 7573746f726530313233343536373839 dpMyN7L5HI8VZEs1biQJ7g== Java: public class CryptUtil { public static final String DEFAULT_KEY = "0123456789"; private static CryptUtil instance; private String chiperKey; private CryptUtil(String chiperKey) { this.chiperKey =

javax.crypto working differently in different versions of Android OS?

限于喜欢 提交于 2019-11-30 12:54:13
问题 I'm using this code snippet to encrypt/decrypt data in my app's database: http://www.androidsnippets.com/encryptdecrypt-strings It appears that the javax.crypto.KeyGenerator.generateKey() operation works differently in Android 2.3.3 OS than in other (previous?) versions. Naturally, this presents a major problem for my users when they upgrade their device from 2.2 to 2.3.3 and the app starts throwing errors decrypting the database. Is this a known issue? Am I using the crypto library

javax.crypto.Cipher working differently since Android 6 Marshmallow

≡放荡痞女 提交于 2019-11-30 10:20:00
I've been successfully using javax.crypto.Cipher.getInstance("DESede/CBC/NoPadding") to Authenticate with DESFire cards on Android (following the example here: https://stackoverflow.com/a/14160507/2095694 ). It's been working on several devices from Android 4 to 5, but stopped working on my Nexus 7 updated to 6 Marshmallow (and 6.0.1). It had been working on the same device before updating. It seems Cipher is working differently, giving different results for the same key and data. Running the following code... public static void testCipher() throws Exception { byte[] KEY = new byte[]{ (byte)

javax.crypto working differently in different versions of Android OS?

妖精的绣舞 提交于 2019-11-30 04:04:22
I'm using this code snippet to encrypt/decrypt data in my app's database: http://www.androidsnippets.com/encryptdecrypt-strings It appears that the javax.crypto.KeyGenerator.generateKey() operation works differently in Android 2.3.3 OS than in other (previous?) versions. Naturally, this presents a major problem for my users when they upgrade their device from 2.2 to 2.3.3 and the app starts throwing errors decrypting the database. Is this a known issue? Am I using the crypto library incorrectly? Anyone have any suggestions on how to address this so that data encrypted in 2.2 is able to be

javax.crypto.Cipher working differently since Android 6 Marshmallow

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 09:41:53
问题 I've been successfully using javax.crypto.Cipher.getInstance("DESede/CBC/NoPadding") to Authenticate with DESFire cards on Android (following the example here: https://stackoverflow.com/a/14160507/2095694). It's been working on several devices from Android 4 to 5, but stopped working on my Nexus 7 updated to 6 Marshmallow (and 6.0.1). It had been working on the same device before updating. It seems Cipher is working differently, giving different results for the same key and data. Running the

PBKDF2WithHmacSHA512 Vs. PBKDF2WithHmacSHA1

百般思念 提交于 2019-11-28 17:34:40
I'm working on a Java authentication subsystem that specs the storage of passwords in the DB as PBKDF2 -generated hashes, and I'm now trying to decide whether I should use SHA1 or SHA512 as PFR. I went through the specs of both but they are very mathematically intensive for me to follow. Can somebody with better crypto-understanding explain how PBKDF2WithHmacSHA512 differs from PBKDF2WithHmacSHA1 ? Here's what I'm trying to do: private static final int HASH_BYTE_SIZE = 64; // 512 bits private static final int PBKDF2_ITERATIONS = 1000; // generate random salt SecureRandom random = new

Why am I getting package javax.crypto does not exist

旧时模样 提交于 2019-11-28 11:57:41
When I compile a class using javax.crypto.Mac I get this error message? package javax.crypto does not exist I can fix it by including jre/lib/jce.jar in my compile classpath. Why is jce.jar not on the default jdk classpath? jre/lib/rt.jar is on the classpath, and includes other javax packages, but jce seems special? Mike Hogan OK, this was a mistake on my part. The Ant file I was using to compile the code had this attribute on the javac task: bootclasspath="${java.home}/lib/rt.jar" Doh. You can add the JCE jar like this: bootclasspath="${java.home}/lib/rt.jar:${java.home}/lib/jce.jar" Beware!

How can I list the available Cipher algorithms?

旧城冷巷雨未停 提交于 2019-11-27 15:26:23
I am getting a Cipher implementation with Cipher.getInstance(String algorithm) . I am under the impression that the available algorithm names that I may pass differ based on what libraries which are present in my classpath. I would like to write a simple program that I can run with different classpaths that will list the available Cipher algorithm names. What method would I need to call to get this list? Once I have a list of providers, as described in JB Nizet's post, I still don't have a list of algorithms. I found that each Provider functions as a Properties object, and the Properties

How can I list the available Cipher algorithms?

拈花ヽ惹草 提交于 2019-11-27 15:26:17
I am getting a Cipher implementation with Cipher.getInstance(String algorithm) . I am under the impression that the available algorithm names that I may pass differ based on what libraries which are present in my classpath. I would like to write a simple program that I can run with different classpaths that will list the available Cipher algorithm names. What method would I need to call to get this list? Once I have a list of providers, as described in JB Nizet's post, I still don't have a list of algorithms. I found that each Provider functions as a Properties object, and the Properties