aes

Java Encryption and Javascript Decryption [closed]

南笙酒味 提交于 2019-12-21 03:03:13
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I am trying to encrypt a data in java and decrypt the same in javascript. There is already a similar question in SO but it does not work for me. My question is - Encrypted Text given by Java code is not getting decrypted by Javascript. I have hardcoded the the encrypted text and key in my JS below.

How to encrypt AES keys using RSA without running into “javax.crypto.IllegalBlockSizeException: Data must not be longer than 117 bytes”

穿精又带淫゛_ 提交于 2019-12-21 03:03:09
问题 I have to build a simple authorization server for a project. The server has to distribute AES keys to allow its clients to communicate with each other. When encrypting the AES key using RSA, I run into this error: "javax.crypto.IllegalBlockSizeException: Data must not be longer than 117 bytes". Which is weird, since the lenght of my AES key is 128 bits = 16 bytes. Here is the code generating the error: private void createAndSendAES() throws NoSuchAlgorithmException, NoSuchPaddingException,

Android KeyStore Initialization

时光毁灭记忆、已成空白 提交于 2019-12-21 02:59:21
问题 First off I am new to android Programming, though I am not new to programming itself. What I am, essentially, trying to do is to save my encryption Keys into the Android Keystore. There seems to be a phenomenal lack of such information on GOOGLE, itself. Since there is not much how-to available on the topic I am assuming that it isn't fairly standard knowledge. So can someone please give me a sample code to Initialize the KeyStore(Will be using AES-256). Save multiple keys in a KeyStore

“Wrong algorithm” Error when trying to Decrypt in Java

泪湿孤枕 提交于 2019-12-21 02:55:11
问题 I am first going to describe the problem which I have, and then give some background to what I am trying to do. Finally I shall paste some relevant code snippets. I am trying to implement secret key encryption/decryption using the method specified in https://stackoverflow.com/a/992413/171993. If I use that example as-is, it works (although I did notice that I need to re-instantiate the Cipher class, otherwise the decryption produces garbage). However, in my implementation I get the following

Android aes encryption pad block corrupted

南笙酒味 提交于 2019-12-21 02:47:39
问题 I am using the methods below and if I enter the right key everything works fine. But if I enter a wrong key I am receiving a BadPaddingException:pad block corrupted... Am I doing something wrong? public void initKey(String passwd, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException{ byte[] localsalt = salt; PBEKeySpec password = new PBEKeySpec(passwd.toCharArray(),localsalt, 1024,128);//, localsalt, 1000, 128); //128bit enc aes SecretKeyFactory

implementing AES256 encryption into IOS

大憨熊 提交于 2019-12-21 02:47:25
问题 This is my java code. Now I want to implement same functionality in Objective-C. Cipher encryptCipher; IvParameterSpec iv = new IvParameterSpec(key); SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); encryptCipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); byte[] encrypted = encryptCipher.doFinal(dataToEncrypt.getBytes()); Log.d("TAG", "encrypted string:" + Base64.encodeToString(encrypted, Base64.DEFAULT)); return Base64

Why is desktop AES file IO incompatible with Android AES file IO?

自闭症网瘾萝莉.ら 提交于 2019-12-21 02:42:13
问题 I have ported an application from Android to desktop that uses AES to encrypt some private data. Both applications are able to encrypt and decrypt the data for their own use but unable to decrypt the other applications data. The AES keys, IVs, and algorithms are identical. The main difference between the two applications is that the android-sdk comes with the BouncyCastle provider already added to the security while the desktop application needed Security.addProvider(new org.bouncycastle.jce

JAVA实现AES加密、解密

余生长醉 提交于 2019-12-21 02:22:28
什么是AES? 高级加密标准 (英语: Advanced Encryption Standard ,缩写: AES ),是一种区块加密标准。这个标准用来替代原先的DES,已经被多方分析且广为全世界所使用。 那么为什么原来的DES会被取代呢,,原因就在于其使用56位密钥,比较容易被破解。而AES可以使用128、192、和256位密钥,并且用128位分组加密和解密数据,相对来说安全很多。完善的加密算法在理论上是无法破解的,除非使用穷尽法。使用穷尽法破解密钥长度在128位以上的加密数据是不现实的,仅存在理论上的可能性。统计显示,即使使用目前世界上运算速度最快的计算机,穷尽128位密钥也要花上几十亿年的时间,更不用说去破解采用256位密钥长度的AES算法了。 目前世界上还有组织在研究如何攻破AES这堵坚厚的墙,但是因为破解时间太长,AES得到保障,但是所用的时间不断缩小。随着计算机计算速度的增快,新算法的出现,AES遭到的攻击只会越来越猛烈,不会停止的。 AES现在广泛用于金融财务、在线交易、无线通信、数字存储等领域,经受了最严格的考验,但说不定哪天就会步DES的后尘。 AES加密工具类的代码(测试代码): import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException;

Cipher.init() required for each message?

浪尽此生 提交于 2019-12-20 20:29:13
问题 Assume two clients are exchanging secure messages back and forth. Must this block be run every time for each message, or can any step(s) be done just once at start: cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); output = cipher.doFinal(content); I guess to lend some context- although I don't (yet) understand the internals completely, it is my understanding that for security purposes it's important to change the IV for each message. So I think

PHP Encrypt and Windows Decrypt

筅森魡賤 提交于 2019-12-20 19:36:39
问题 I 'm stuck. It seems that AES encryption done by PHP cannot be decrypted in windows. PHP code: $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128,"12345678", "test", MCRYPT_MODE_CBC)); Windows Code: "s" has the string which is created by the above response after converting back from base64. bool Decrypt(char* s,char* key,char* dest) { // Create the crypto provider context. HCRYPTPROV hProvider = NULL; if (!CryptAcquireContext(&hProvider, NULL, // pszContainer = no named container