aes

How can I encrypt and decrypt using AES 128 without an IV?

帅比萌擦擦* 提交于 2019-11-29 00:28:15
I'm currently needing a way to encrypt a string and decrypt a byte array using AES-128 symmetrical encryption, in C#. I can't find a way how to do this, but maybe I've missed something. Arif Ansari Import namespaces using System; using System.IO; using System.Text; using System.Security.Cryptography; static void Main(string[] args) { string value = "@arifansari300<3>"; string encryptedValue= EncryptDecrypt.Encrypt(value); string decryptedValue = EncryptDecrypt.Decrypt(encryptedValue); } public static string Encrypt(string clearText) { string EncryptionKey = "MAKV2SPBNI99212"; byte[] clearBytes

AES encrypt with openssl decrypt using java

僤鯓⒐⒋嵵緔 提交于 2019-11-28 23:52:00
I have to encrypt an xml file using openssl command line or a C api. The output shall be Base64. A java programm will be used for decrypting. This programm is provided by the customer and cannot be changed (they are using this code for legacy applications). As you can see in the code below the customer provides a passphrase so the key will be generated using the SecretKeySpec method. Java code: // Passphrase private static final byte[] pass = new byte[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0','1', '2', '3', '4', '5' }; public static String encrypt(String Data) throws Exception

Node.js and crypto library

一曲冷凌霜 提交于 2019-11-28 23:50:11
I'm having weird issues with Node's crypto library. I wrote this simple AES testing script: var cipher = crypto.createCipher('aes-256-cbc','InmbuvP6Z8') var text = "123|123123123123123"; cipher.update(text,'utf8','hex') var crypted = cipher.final('hex') var decipher = crypto.createDecipher('aes-256-cbc','InmbuvP6Z8') decipher.update(crypted,'hex','utf8') var dec = decipher.final('utf8') When I do console.log(dec), it's null. For some reason if I set test to "123|123123", it works. So why does "123|123123" work but "123|123123123123123" doesn't? RandomEtc You need to store the return from

How to get compatibility between C# and SQL2k8 AES Encryption?

谁都会走 提交于 2019-11-28 23:43:33
I have an AES encryption being made on two columns: one of these columns is stored at a SQL Server 2000 database; the other is stored at a SQL Server 2008 database. As the first column's database (2000) doesn't have native functionality for encryption / decryption, we've decided to do the cryptography logic at application level, with .NET classes, for both. But as the second column's database (2008) allow this kind of functionality, we'd like to make the data migration using the database functions to be faster, since the data migration in SQL 2k is much smaller than this second and it will

Rewrite PHP Rijndael algorithm to Java (Android)

怎甘沉沦 提交于 2019-11-28 22:09:14
I need to encode a string in Java and php where the result must be the same. The following conditions are given: algorithm: RIJNDAEL-128 key: 5P443m2Q1R9A7f5r3e1z08642 mode: ECB initialization vector: N/A (Since we're using ECB, IV's are ignored) String to encode: 201412181656005P443m2Q1R9A7f5r3e1z08642 PHP <?php class Cipher { private $securekey, $iv; function __construct($textkey) { $this->securekey = $textkey; $this->iv = mcrypt_create_iv(32); } function encryptR($input) { $enc = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv); return base64_encode(

AES 256 encryption in C++ and Qt 5

对着背影说爱祢 提交于 2019-11-28 20:39:33
问题 I have a Java code for encryption in place as follows! private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception { SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = null; if(isIVUsedForCrypto) { cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(IV)); } else { cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); } byte[] encrypted = cipher.doFinal(clear); return

Android AES 256-bit Encrypt data

帅比萌擦擦* 提交于 2019-11-28 20:38:28
问题 So I've seen a lot of examples, and done a lot of googling, and looked at examples on Stack Overflow... and I need help. I've got an Android application and I'm storing username and passwords on the device, and I need to encrypt them AES 256. From looking at examples, this is what I have so far: public class Security { Cipher ecipher; Cipher dcipher; // 8-byte Salt byte[] salt = { (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32, (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03 }; // Iteration

Slow AES decryption in Android

雨燕双飞 提交于 2019-11-28 19:56:18
I tried to decrypt a 4.2 MB .dcf file using AES 128 bit key, but it took 33 seconds to decrypt (on function cipher.doFinal(data)), is it normal ? Here is a code snippet: long start = System.currentTimeMillis()/1000L; try { SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivspec); android.util.Log.d("TEST", "Start decoding...." + String.valueOf(length)); byte[] decrypted = cipher.doFinal(content); File file2 = new File(Environment.getExternalStorageDirectory().getPath() + "/test.mp3");

Encrypt AES with C# to match Java encryption

你说的曾经没有我的故事 提交于 2019-11-28 19:52:35
I have been given a Java implementation for encryption but unfortunately we are a .net shop and I have no way of incorporating the Java into our solution. Sadly, I'm also not a Java guy so I've been fighting with this for a few days and thought I'd finally turn here for help. I've searched high and low for a way to match the way the Java encryption is working and I've come to the resolution that I need to use RijndaelManaged in c#. I'm actually really close. The strings that I'm returning in c# are matching the first half, but the second half are different. Here is a snippet of the java

Generating random IV for AES in Java

做~自己de王妃 提交于 2019-11-28 19:52:12
I'm implementing and AES encryption engine for PBE in android, and I've found two ways to implement the creation of the IV and I would like to know which one is better and more secure for getting IvParameterSpec : Method #1: SecureRandom randomSecureRandom = SecureRandom.getInstance("SHA1PRNG"); byte[] iv = new byte[cipher.getBlockSize()]; randomSecureRandom.nextBytes(iv); IvParameterSpec ivParams = new IvParameterSpec(iv); Method #2: AlgorithmParameters params = cipher.getParameters(); byte[] iv2 = params.getParameterSpec(IvParameterSpec.class).getIV(); ivParams = new IvParameterSpec(iv2); I