aes

Decrypting bytes encrypted by .NET's RijndaelManaged using Java

强颜欢笑 提交于 2019-12-03 13:40:29
问题 I am trying to decrypt something, which was encrypted using RijndaelManaged of .NET/C#, using Java to decrypt. The C# program is not mine; I cannot change it to be more interoperable. But I know how it is encrypting: byte[] bytes = new UnicodeEncoding().GetBytes(password); // edit: built-in is 8chars FileStream fileStream = new FileStream(outputFile, FileMode.Create); RijndaelManaged rijndaelManaged = new RijndaelManaged(); CryptoStream cryptoStream = new CryptoStream((Stream) fileStream,

Python AES decryption

喜夏-厌秋 提交于 2019-12-03 13:36:26
问题 I have the following piece of code in Java that I want to replicate in Python. public class AESDecryption { protected SecretKeySpec getPublicKey() { try { byte[] key = "MuidKeibimbtjph9".getBytes("UTF-8"); key = MessageDigest.getInstance("SHA-256").digest(key); key = Arrays.copyOf(key, 32); return new SecretKeySpec(key, "AES"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } public String decrypt(byte

AES with CommonCrypto uses too much memory - Objective-C

狂风中的少年 提交于 2019-12-03 13:07:51
My goal is to be able to, being given a file/folder and a password, encrypt and decrypt it in AES using Objective-C. I'm no crypto nerd or anything, but I chose AES because I found it was pretty standard and very secure. I am using a NSMutableData category which has methods for encrypting and decrypting it's data. Here it is: - (NSInteger)AES256EncryptionWithKey: (NSString*)key { // The key should be 32 bytes for AES256, will be null-padded otherwise char keyPtr[kCCKeySizeAES256 + 1]; // room for terminator (unused) bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding) // Fetch key

Java AES CBC Decryption

倖福魔咒の 提交于 2019-12-03 13:00:22
问题 PHP Encrypt Function $privateKey = "1234567812345678"; $iv = "1234567812345678"; $data = "Test string"; $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $privateKey, $data, MCRYPT_MODE_CBC, $iv); echo(base64_encode($encrypted)); Result: iz1qFlQJfs6Ycp+gcc2z4w== When I try to decrypt this result in Java using the function below, all I get back is ì�š@ÔBKxnfÈ~¯Ô'M while I am expecting "Test string". Any ideas where I am wrong? Thanks public static String decrypt() throws Exception{ try{ String

How to encrypt data using AES in Java

♀尐吖头ヾ 提交于 2019-12-03 12:52:22
I wish to encrypt a piece of data using AES (cbc) in java , I Want to use my own IV, which I have held in a byte array and my own key held in a byte array. How would I go about doing this? I'm searching for it to find tutorials on this topic. This is probably the best guide that I've found on the subject. It explains the basics, one concept at a time, in simple terms. Arshad shaik Formally it encrypts the string into unreadable format. Use same code to decrypt. ENCRYPT: String s1="arshad"; char[] s2=s1.toCharArray(); int s3= s2.length; System.out.println(s3); int i=0; // for(int j=0;j<s3;j++)

How to store the key used to encrypt files

会有一股神秘感。 提交于 2019-12-03 12:43:01
问题 I'm playing around with an app to backup files to "the cloud" :) and I want to encrypt the files before I store them. That part I have covered, but as this app will be monitoring folders for change and uploading the changed files I need to store the key that I use to encrypt the files with. The idea is that the user provides a password and a key is generated. At the moment I'm using the .NET Framework to do the encryption. I'm using the RijndaelManaged class to encrypt/decrypt and the

How to encrypt / decrypt AES with Libsodium-PHP

雨燕双飞 提交于 2019-12-03 12:37:33
I need to encrypt/decrypt data with PHP. I am completely new to this, however I have read that Libsodium-PHP is the best tool for AES encryption. Much like the other PHP encryption libraries I have researched Libsoduim-PHP seemed to offer almost no documentation of how to use the library (that I was able to find). Can anyone that has experience with PHP encryption either point me in the direction of a good learning resource or write a few lines of sample code using Libsoduim-PHP? Thank you very much for the help, Atlas Much like the other PHP encryption libraries I have researched Libsoduim

Easy to use Python encryption library/wrapper?

白昼怎懂夜的黑 提交于 2019-12-03 12:23:59
I want to encrypt an arbitrary-length string with a password in Python. I would prefer not to deal with padding, key generation and IVs as I honestly don't know that much about cryptography yet and I'd like to avoid messing up. I'd also prefer using a well-known cypher as AES. My ideal library (let's call it MagicCrypt) would work like this: from MagicCrypt import AES p = "plaintext" k = "password" crypt = AES(k) c = crypt.encrypt(p) p == crypt.decrypt(c) # True I've checked PyCrypto , m2crypto , pycryptopp , GPGme and keyczar . Neither of them seem to offer this really easy to use mode.

Stopping decryption before EOF throws exception: Padding is invalid and cannot be removed

自作多情 提交于 2019-12-03 12:19:46
This is the scenario we have: We have huge encrypted files, in the order of gigabytes that we can decrypt correctly if we read them until the end. The problem arises when we are reading and detect some flag in the file, then we stop reading and call reader.Close(), what happens is that a CryptographicException: "Padding is invalid and cannot be removed." is thrown. I have this small console app that reproduce this behavior, to test it just run it, it will create a file in your C:\ drive and then it will read line by line when pressing any key, and will stop when pressing 'q'. using System;

Python AES encryption without extra module

人走茶凉 提交于 2019-12-03 12:06:28
Is it possible to encrypt/decrypt data with AES without installing extra modules? I need to send/recieve data from C# , wich is encrypted with the System.Security.Cryptography reference. UPDATE I have tried to use PyAES, but that is too old. I updated some things to make that work, but it didn't. I've also can't install because it latest version is 3.3 while my version is 3.4 . The available Cryptographic Services available in the Standard Library are those . As you can see AES is not listed, but is suggest to use pycrypto which is an extra module . You just have to install it using pip , or