aes

How to Encrypt/Decrypt text in a file in Java

主宰稳场 提交于 2019-12-04 13:36:39
问题 I have a problem with my code, when I encrypt data, for example, in this case, the simmetric key I encrypted with the receiver's public key, then saved to a text file, when I read that text file and try to decrypt it, using the receiver's private key, I get a different key, therefore I cannot use it to decrypt the encrypted message. Sender's code: import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.security.KeyStore;

Android encryption/decryption issue (AES)

青春壹個敷衍的年華 提交于 2019-12-04 13:35:22
问题 I need a little help here.So basically I have to make a test of AES encryption/decryption of an image in Android.I'm new in android programming and that's why a friend of mine give me an example of how to do it, but the problem is that when I run the sample it crashes after like 20-30 seconds and I'm not really sure what's happening.So can anyone please look at the code and tell me where is the problem.The sample code needs to do this : Encrypt and Decrypt the same image and show me a log

Wanted Compatible AES code Encrypt/Decrypt for Iphone, Android, Windows/XP

淺唱寂寞╮ 提交于 2019-12-04 13:16:27
问题 I need to be able to send secure information to a variety of phones from Windows. I am a total novice in both iPhone and Android development, but need to create an easy to use app for each environment. Interfacing with received SMS text messages would also be nice. I would like to acquire code for AES 256 encryption for the iPhone, Android and Windows XP (and up). Thanks Murray 回答1: Few important things to note while implementing AES encryption: 1. Never use plain text as encryption key.

Decrypting file in C++, which was encrypted with openssl -aes-128-cbc

不问归期 提交于 2019-12-04 12:57:55
I'm trying to decrypt a file in C++. This file is encrypted with the following command: openssl enc -nosalt -aes-128-cbc -pass pass:test -in "test.txt" -out "test_enc.txt" -p The console shows the key=098F6BCD4621D373CADE4E832627B4F6 and iv=0A9172716AE6428409885B8B829CCB05 . In C++ I have included the #include openssl/aes.h line and try to decrypt with the following code: const char *indata = string.toAscii().constData(); unsigned char outdata[strlen(indata)]; unsigned char ckey[] = "098F6BCD4621D373CADE4E832627B4F6"; unsigned char ivec[] = "0A9172716AE6428409885B8B829CCB05"; /* data structure

Using PHP mcrypt with Rijndael/AES

霸气de小男生 提交于 2019-12-04 12:02:38
问题 I am trying to encrypt some text messages using mcrypt from php and the cipher Rijndael, but I am not sure about the MCRYPT_MODE_modename (according to PHP's manual these are available "ecb", "cbc", "cfb", "ofb", "nofb" or "stream" but I read there are actually a few more). I have no idea what each one do or how to use them. I read two things, that ECB mode should not be used and MCRYPT_RAND neither. They didn't explain why. For the ECB mode I guess it's because it always generate the same

java aes javax.crypto.BadPaddingException: Given final block not properly padded

你说的曾经没有我的故事 提交于 2019-12-04 11:52:53
问题 public class AES { public String getEncrypt(String pass){ String password = encrypt(pass); return password; } public String getDecrypt(String pass){ String key = "AesSEcREtkeyABCD"; byte[] passwordByte = decrypt(key,pass); String password = new String(passwordByte); return password; } private byte[] decrypt(String key, String encrypted) { try { SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, new

Seeking in AES-CTR-encrypted input

家住魔仙堡 提交于 2019-12-04 11:25:06
问题 As AES in CTR mode is great for random access, lets say I have a data source created with a CipherOutputStream in AES-CTR mode. The library underneath—which is not mine—uses a RandomAccessFile that allows to seek to a specific byte offset in the file. My initial thought would be to use a CipherInputStream with a Cipher initialized with the right parameters, but the API for that doesn't do seeking and states to not support mark and reset . Is there a part of the API that I've missed that can

Client server AES encryption

半世苍凉 提交于 2019-12-04 11:24:41
I am developing a client server application in which data is transferred between two clients through the server. The data should be encrypted and I thought of using AES . My thought was to use PBKDF2 in order to derive the AES key from the client's password. In this case the client will encode the data, the server will decode it, reencode it using the 2nd client's password and send it to the 2nd client. Do you think this is the best way to implement this? Is there a way for the first client to encode and the 2nd client to decode without server interference? How can I encrypt the AES key and

How to decrypt a cryptojs AES encrypted message at the java server side?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 10:36:53
问题 I have the following cryptojs based javascript encryption/decryption functions which works perfectly fine. I use a random salt, random iv value and a specific password while encrypting the message using cryptpjs. I reuse the same salt, iv and the password to generate the key while decrypting the encrypted message. This part works well.. function encrypt(){ var salt = CryptoJS.lib.WordArray.random(128/8); var iv = CryptoJS.lib.WordArray.random(128/8); console.log('salt '+ salt ); console.log(

How to use AES_ENCRYPT properly?

十年热恋 提交于 2019-12-04 10:23:51
I'm trying to use AES encryption ( AES_ENCRYPT in MySQL) for user passwords but I came up with a bunch of different problems. This is the SQL query that I use to store a new user into the database: INSERT INTO user VALUES ( '15', 'John', 'Doe', '123 Fake St.', AES_ENCRYPT('mypassword', 'mysalt'), 'mysalt' ) Where the salt would be a random string in a real case. It works fine. I mean, I'm able to retrieve the original password. In this example, AES_DECRYPT(user.password, 'mysalt') WHERE user.id = 15 retrieves mypassword . But I might be overlooking some things. Is it secure to save the salt