aes

How to decrypt a file in javascript which is encrypted by JAVA with AES

时光总嘲笑我的痴心妄想 提交于 2019-12-05 10:53:55
问题 I have encrypted JPG file in Java with AES256, but have no idea to decrypt the JPG file in javascript. Anyone has better idea? I'm struggling with it for 4days. byte[] ivBytes = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; String key = "1234567890123456789012345678901d"; AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes); SecretKeySpec newKey = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); Cipher cipher = Cipher.getInstance(

Encrypt a file appending IVSBytes in unique file - Execption: Given final block not properly padded

谁说我不能喝 提交于 2019-12-05 10:53:28
问题 I'm trying to encrypt a file using AES with a SHA-256 Key. When I generate the IVs I preppend it at the beggining of the encrypted file, and append the rest. When I recover the IV's and compare it (the IV's after and then of the proces) they are the same. The problem is when I try to decrypt the file: javax.crypto.BadPaddingException: Given final block not properly padded I think it could be because i don't read properly the following bytes, but I revise the code and it seems Ok. Crypto class

How to update part of the encrypted data with newly encrypted data?

拈花ヽ惹草 提交于 2019-12-05 10:53:10
问题 I need to encrypt an audio file while it is being generated. I am encrypting header with dummy data(because I don't know the actual size of audio data) at the starting and encrypting the audio data on the fly. My plan is to update the header at the end with actual data size of audio file. But, When I tried to overwrite the encrypted header data with newly encrypted header data of same size by using same key and IV and try to decrypt later, I am getting junk data generated. Why is this

Application deadlocks when creating cipher streams from socket

无人久伴 提交于 2019-12-05 10:51:34
问题 I'm having problems encrypting and decrypting my streams between two sockets. ObjectInputStream oIn = new ObjectInputStream(new FileInputStream(new File("key"))); SecretKeySpec spec = (SecretKeySpec) oIn.readObject(); //'key' file was saved previously Cipher cEncrypt = Cipher.getInstance("AES"); cEncrypt.init(Cipher.ENCRYPT_MODE, spec); Cipher cDecrypt = Cipher.getInstance("AES"); cDecrypt.init(Cipher.DECRYPT_MODE, spec); //should have no problems here, I tried the ciphers out by encoding and

.NET's SslStream is always negotiating to the least secure cipher I have. How can I change this?

不羁的心 提交于 2019-12-05 10:49:14
SslStream is supposed to negotiate the cipher type, key length, hash algorithm, etc. with its peer SSL stack. When using it in my code, I find that the negotiation always defaults to RC4 & MD5. I would like to use 3DES or AES for some added security. Looking around the web I find only a few references to this problem and no solutions; one poster is claiming this actually makes sense, since the lowest common denominator between the two stacks is secure while has the added benefit of being faster/using less CPU resources. While this may be technically correct, my particular trade-off between

For AES128 using CCCrypt() can the key be longer than 128 bits?

房东的猫 提交于 2019-12-05 10:49:12
I am using the CCCrypt method. Can I use a longer key than than 128bit? Can it be arbitrarily long? Or perhaps multiples of 128? If so how would I do this? I didn't think this woas possible but I found this text: here Some algorithms such as AES and RSA allow for keys of different lengths , but others are fixed, such as DES and 3DES. Encryption using a longer key generally implies a stronger resistance to message recovery. As usual, there is a trade off between security and time, so choose the key length appropriately. How does AES allow for different lengths, does it ignore the bits higher

Why do I get BadPaddingException when trying to encrypt a string?

不打扰是莪最后的温柔 提交于 2019-12-05 10:42:15
问题 I create an Encryption class to encryt/decrypt binary data in my Android project, by this link. package com.my.package; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; // TODO Incomplete class public class Encryption { private static final byte[] salt = { (byte) 0xA4, (byte) 0x0B, (byte) 0xC8, (byte) 0x34, (byte) 0xD6, (byte) 0x95, (byte) 0xF3, (byte) 0x13 }; private static

Decrypt string using AES/CBC/NoPadding algorithm

流过昼夜 提交于 2019-12-05 09:16:27
I want to decrypt an Encrypted Sting using AES/CBC/Nopadding in c# Windows Phone 8 application. My string is in file of IsolatedSorage . I pasted the string HERE which is junk. From this Article I am using AesManaged class to decrypt. But how to set padding to NoPadding because by default the padding set to PKCS7 from here. string fileName = "titlepage.xhtml"; if (fileStorage.FileExists(fileName)) { IsolatedStorageFileStream someStream = fileStorage.OpenFile(fileName, System.IO.FileMode.Open, FileAccess.Read); using (StreamReader reader = new StreamReader(someStream)) { str1 = reader.ReadToEnd

Java Cipher - PBE thread-safety issue

瘦欲@ 提交于 2019-12-05 08:46:01
It seems that I have a thread-safety issue with Cipher and/or PBEKeySpec. JDK : 1.8.0_102, 1.8.0_151 and 9.0.1+11 PBKDF2 algorithm: PBKDF2WithHmacSHA1 Cipher algorithm: AES/CFB/NoPadding Key algorithm: AES I know these classes aren't tread-safe if we use the same instances, but that's not the case, I'm getting a new instance at each decode. But even that, sometimes the decode fails, there is no exception, just an unexpected decoded value. I've been able to reproduce the problem: @Test public void shouldBeThreadSafe() { final byte[] encoded = { 27, 26, 18, 88, 84, -87, -40, -91, 70, -74, 87,

Pycrypto : AES Decryption

坚强是说给别人听的谎言 提交于 2019-12-05 08:23:11
Why Pycrypto AES decryption gives different output when decrypted with AES object used for encryption and right output when decrypted with AES object used solely for decryption? from Crypto.Cipher import AES obj = AES.new('0123456789012345', AES.MODE_CBC, '0123456789012345') message = '0123456789012345' ciphertext = obj.encrypt(message) plaintext = obj.decrypt(ciphertext) # plaintext here is byte array obj2 = AES.new('0123456789012345', AES.MODE_CBC, '0123456789012345') plaintext = obj2.decrypt(ciphertext) # plaintext here is 0123456789012345 According to BlockAlgo#encrypt from which the AES