FAQ Database Discussion Community


PumpMessages in crypto++, reading a key file?

c++,file-io,aes,crypto++
I'm writing an AES key and iv to the file with crypto++ by using following code: // write the key: SecByteBlock key(AES::DEFAULT_KEYLENGTH); SecByteBlock iv(AES::BLOCKSIZE); string file = m_file_name + ".key"; FileSink* key_out = new FileSink(file.c_str()); Base64Encoder base64_key_enc(key_out); base64_key_enc.Put(key.BytePtr(), key.size()); base64_key_enc.MessageEnd(); base64_key_enc.Put(iv.BytePtr(), iv.size()); base64_key_enc.MessageEnd(); and to read a the key and...

MS SQL column encryption without certificate

sql,sql-server,encryption,aes,x509certificate
I am trying to encrypt one of my sensitive columns in a SQL Server table. I tried AES256 encryption with this script, and it works perfect. But I don't want to create Certificates, or Symmetric Keys on my SQL Server as it may be a security problem later. How can...

Source text, key size relationship for encryption/decryption in Go

encryption,go,cryptography,aes,rsa
In the code below (also at http://play.golang.org/p/77fRvrDa4A but takes "too long to process" in the browser there) the 124 byte version of the sourceText won't encrypt because: "message too long for RSA public key size" of 1024. It, and the longer 124 byte sourceText version, work with 2048 bit key...

java AES/CFB/NoPadding :when encrypting similar data the results are similar too

java,encryption,aes
package com.game; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.io.UnsupportedEncodingException; public class MainTest5 { public static byte[] encrypt(String content, String key) { try { Cipher aesECB = Cipher.getInstance("AES/CFB/NoPadding"); SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES"); IvParameterSpec ivSpec = new IvParameterSpec(key.getBytes()); aesECB.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec); byte[] result =...

How to encrypt in php5 and decrypt in windows store 8.1 and c# using aescbc

c#,php,encryption,windows-store-apps,aes
Hi guys I have encrypted the word hello in a string in PHP using the AesCbc method. Here is my code. base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128,'1234567890123456',pkcs7_pad('hello', 16),MCRYPT_MODE_CBC)) The result is 67fHA+Z12z2jlwOLTBeCPA== I then send this result to my windows store application and this is the function I use to decrypt it. public string AES_Decrypt(string...

Java to JS and JS to Java encryption using cryptojs

java,encryption,encoding,aes,cryptojs
I got on this post a couple of weeks ago and worked perfectly: Compatible AES algorithm for Java and Javascript Now, I need to do the reverse operation, but once in java, I am getting this exception: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:966) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436)...

AES decrypt with encrypt hardware

encryption,aes,hardware
I am using Nordic Nrf51822 chip, it has AES encrypt hardware support, but no decrypt hardware support, so I come up with following method sender -> XOR(data, AES(XOR(salt, counter = 1)) -> receiver receiver is able to XOR back the data. is there a better way, i.e. if AES is...

Node.js crypto key and iv to match java SecretKeySpec / IvParameterSpec

node.js,encryption,cryptography,aes,padding
I'm trying to to port a Java (simple) encryption algorythm to Node JS. I will need to be able to decrypt/encrypt stuff encrypted/decrypted from the Java side. I'm stuck at the very beginning, the initialization of the cipher. In Java, I get the key with SecretKeySpec, and the Initialization Vector...

Android AES Encryption from C# to Java

java,c#,android,encryption,aes
I am converting my C# encryption code to Android. I am facing issue like I am not able to encrypt the text as same as C#. Below I copy paste both code. Both are working code regarding using it you can use any password & any plain text .You will...

AES decryption only works for first 16 characters

c++,encryption,openssl,aes
I'm trying to get a simple AES encrypt/decrypt going using c++ for my computer science class. It works almost perfectly, but the decryption will only work on the first 16 characters of the character array. Here's my code: #include <iostream> #include "openssl/aes.h" using namespace std; int main() { unsigned char...

Decrypt with AES (MODE_CBC/NoPadding) a file in iOS encrypted in Python

android,python,ios,encryption,aes
I receive from a Server in Python a file encrypted in this manner: import os from Crypto.Cipher import AES from Crypto import Random def pad(s): return s + b"\0" * (AES.block_size - len(s) % AES.block_size) def encrypt(message, key): message = pad(message) iv = Random.new().read(AES.block_size) cipher = AES.new(key, AES.MODE_CBC, iv) return...

javax.crypto.BadPaddingException: pad block corrupted exception

java,encryption,cryptography,aes,bouncycastle
I get Exception in thread "main" javax.crypto.BadPaddingException: pad block corrupted at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher$BufferedGenericBlockCipher.doFinal(Unknown Source) at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineDoFinal(Unknown Source) at javax.crypto.Cipher.doFinal(Cipher.java:2087) at Server.main(Server.java:67) when I'm trying to run an application between a Client and a Server. The Server class: public class Server { private static SecretKeySpec AES_Key; private static...

R - Interpreting a subscript in a variable used in ggplot

r,ggplot2,aes,subscript
I'm using ggplot to do some multiline plots that are constructed with lots of variables and the use of paste. I have not been able to figure out how to get the subscript 3 in O3 to appear in the following simplified version of the code. gasSubscript <- "O[3]" color1...

sync AES ecnryption between cryptoJS and openSSL (ruby)

ruby-on-rails,encryption,openssl,aes,cryptojs
I can't get same result when encrypting using CryptoJS or Ruby's OpenSSL JS code k=CryptoJS.enc.Hex.parse('ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'); iv=CryptoJS.enc.Hex.parse('3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d'); r=CryptoJS.AES.encrypt("hello", k, { iv: iv }); alert(r.ciphertext.toString(CryptoJS.enc.Base64)); and in Rails cipher = OpenSSL::Cipher::AES.new(256, :CBC) cipher.encrypt cipher.key = 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb' cipher.iv =...

can I use a keystore generated by java keytool in a different jre implementation

java,encryption,aes
I want to encode/decode a string in two different java environment and those enviroments use different jre implementations. Can I use a keystore generated in IBM jre implementation, in oracle jre implementation ?

AES decryption with bouncy castle

java,encryption,cryptography,aes,bouncycastle
I am attempting to adapt the sample code at http://www.java2s.com/Code/Java/Security/Basicsymmetricencryptionexample.htm to have to be invoked with 3 arguments, the mode (encryption or decryption), IV and the key. It also reads and writes to specific files. As of right now I am ignoring the given IV and key until I get...

Issues with AES Encryption using SynCrypto

delphi,encryption,cryptography,aes
Am trying to encrypt a file using SynCrypto.pas with AES 256, but it fails if I try to encrypt a file whose size is not a multiple of 16 bytes. The decrypted data contains junk. Example: Original string in txt file we are testing the file Encrypted String [ù[„|wáî}f *!4ìÙw¬•ü¨s...

C# Decrypting mp3 file using RijndaelManaged and CryptoStream

c#,azure,encryption,aes
I have decrypted and saved an mp3 file into a blob storage. However, when I decrypt and download the file I cant play it. I used an Mp3 validation tool which says "unknown file format". I believe it is the decryption that does not work since it works to download...

Creating My Symmetric Key in C#

c#,security,encryption,cryptography,aes
Have been reviewing some symmetric cryptography approaches I've seen a lot of examples that hard code a private static variable in a class, usually something along the lines of: string key = "THISISYOURENCRYPTIONKEY!" and then somewhere further down, the code uses it for encrypting/decrypting. Putting aside the correct implementation/algorithm/strategy as...

AES, 128 and 256 Invalid Key Length

c++,encryption,aes,crypto++,aes-gcm
I am trying to encrypt a text using Crypto++. It worked well last time when using AES CTR, but now when using CBC or GCM the max key length I can use is 32 bits?? The code that handles the encryption: string xAESPlain, xAESCipher; AutoSeededRandomPool xRng; byte xAESKey[128]; // Doesnt...

Is it OK to encode data using key equal to data?

encryption,cryptography,aes
For some project, I need to store some short string in encrypted form. It would be ideal for the current purposes to encrypt it using itself. # This would be the usual way: result = AES_ENCRYPT(string, key) # but I would like to do it this way: result = AES_ENCRYPT(string,...

IllegalBlockSizeException when trying to encrypt and decrypt a string with AES

java,android,encryption,aes
I have a hardcoded key with which I want to encrypt a string before storing it in SharedPreferences. This is the code I have so far: public class TokenEncryptor { private final static String TOKEN_KEY = "91a29fa7w46d8x41"; public static String encrypt(String plain) { try { Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); AlgorithmParameterSpec...

NFC Reader Cannot Read Encrypted Card Emulation Data

android,encryption,aes,arduino-uno
I'm currently using Seeed Studio's NFC Shield v2 and Arduino Uno R3. Here's the code from the sketch that I'm using to read. It based on the example provided by Seeed Studio Android HCE libraries: void loop() { ... uint8_t response[510]; uint8_t responseLen = sizeof(response); success = nfc.inDataExchange(selectApdu, sizeof(selectApdu), response,...

AES-256 Password Based Encryption/Decryption in Java

java,encryption,passwords,aes,password-encryption
I found a guide for implementing AES encryption/decryption in Java and tried to understand each line as I put it into my own solution. However, I don't fully understand it and am having issues as a result. The end goal is to have passphrase based encryption/decryption. I've read other articles/stackoverflow...

C# AES and RSA File Encryption - How to use IV?

c#,encryption,cryptography,aes,rsa
I'm writing a program at the moment that works under the following scenario: I've got some confidential log files that I need to backup to a server. I have a program that generates these log files every day. These log files would rarely if ever need to be opened. I...

Concatenating MAC and salt with ciphertext

java,encryption,cryptography,aes,hmac
I've been having trouble adding a MAC to my password-based AES encryption/decryption program. I am trying to add the MAC'd plaintext and salt (to be used with password) (both byte arrays) to a final array along with the ciphertext, and then decrypt by reading in the ciphertext file and splitting...

Can I specify the nonce and counter in AES encryption counter mode?

encryption,aes,crypto++
I'm trying to use the library Crypto++ to make AES Counter mode based encryption/decryption I want to split the IV value into nonce and counter. Is there any API that directly takes the nonce and counter to construct the IV ? I did the following to achieve it byte counter[AES::BLOCKSIZE/2]...

Encryption of strings using AES 128 in Java/grails

java,grails,encryption,aes
I would like to encrypt 3 strings using AES 128 in Java / Grails, and using the code below, but i get the error "An error occurred when encrypting", can someone tell me what is wrong with my code, how to fix it. thanks in advance and to Stackoverflow. String...

How to use AES CBC using a key longer than 256 bits in Python

python,encryption,aes
Anyone have a way to encrypt/decrypt using Python to handle AES in CBC mode with a key of 1024 bits (128 bytes)? All the AES pkgs found so far seem to be limited to 256 bit keys. My crypto background is limited....

AES Encryption error: javax.crypto.BadPaddingException

java,encryption,aes,javax.crypto,badpaddingexception
I'm getting the following error with this code: javax.crypto.BadPaddingException: Given final block not properly padded. I pointed out where the error is occurring in the program. package aes; import javax.crypto.*; import java.security.*; import javax.crypto.spec.SecretKeySpec; import sun.misc.*; public class AESencrpytion { //private static final byte[] keyValue = new byte[]{'S','e','c','r','e','t'}; public static...

Encryption/decryption between Java and Android

java,android,security,aes
I am using the same code on Java SE and Android project. The apps running in Java and Android connect to the same MQTT broker and exchange messages. The messages are encrypted/decrypted using AES. I have very little experience with Java Security Architecture, so my questions are: 1) What should...

Code fails for decrypting without salt or iv in Java

java,security,encryption,aes,password-encryption
I have a ciphertext and a 256-bit key to decrypt it, using AES. There is no salt or iv. I am using Java. I have implemented many of the solutions online, but they all use salts and input vectors. The following builds fine, but fails at runtime: "Salt not found."...

Is it possible to implement AES with a 64-bit I/O block size?

security,encryption,cryptography,aes
I'm working on an application with a very specific encryption requirement: We are required to encrypt/decrypt individual 64-bit values, to protect certain parts of our internal architecture from reverse engineering through our public web endpoints. The problem is, the existing 64-bit encryption methods (such as 3DES) are not secure enough...

AES encryption/decryption from Android to server

java,android,encryption,aes
I have one server and two clients. The server runs with Java and Jersey (Rest). One client is a Java client and the other is an Android client. I want to send message encrypted with AES. So I have this code (on the server and clients) : cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");...

Error while sending encrypted data with Boost::asio::async_send_to

c++,encryption,aes,boost-asio,crypto++
I am developing an encrypted version of a realtime communication application. The issue I have is, that the encrypted data pakets sent to the receiver are faulty. An example from the error log: (hex encoded data, the original data is pure byte code). sent: 262C1688215232656B5235B691826A21C51D37A99413050BAEADB81D8892493FC0DB519250199F5BE73E18F2703946593C4F6CEA396A168B3313FA689DE84F380606ED3C322F2ADFC561B9F1571E29DF5870B59D2FCF497E01D9CD5DFCED743559C3EE5B00678966C8D73EA3A5CD810BB848309CDF0F955F949FDBA618C401DA70A10C36063261C5DBAB0FC0F1...

AES with PKCS#5 padding

java,encryption,aes,bouncycastle,jce
In quite a few places, I see Java code that uses AES with PKCS#5 padding. I do not understand how this could possible work. PKCS#5 padding is meant to be used with ciphers that have a block size of <= 8 bytes. The block size for AES is 16 bytes....

AES Key generation (C#)

c#,encryption,key,aes
i'm working on this project that uses AES encryption. The encryption / decryption part is all done, but I can't get the random AES key generator to work.. I tried multiple things, but I can't get them to work.. Help would be appreciated Regards, CmplDev...

AES encryption C++ (can't decrypt encrypted file)

c++,encryption,cryptography,aes
I'm playing around with AES and write the iv and derived key to the file so that I use it later for decryption... following function encrypts the file and saves the iv and derived key into the file, it also saves encrypted text into separate file: void MainWindow::on_button_encrypt() try {...

Given Final Block not properly padded while AES decryption

java,encryption,cryptography,aes,cryptojs
First, I'll tell what is my primary goal. I'm going to use AES to encrypt some content in the client side, then use RSA public key to encrypt the important AES specs and sending both AES encrypted data and RSA encrypted AES specs to server. So at server, I'll decrypt...

MySQL AES_DECRYPT wrong/strange result

mysql,encryption,aes
Under my development machine WAMP, AES_ENCRYPT and AES_DECRYPT is not working as required, also i tested with ENCODE and DECODE and same happen... I'm not understading why... SELECT AES_ENCRYPT('text', SHA1('My secret passphrase')) as enc, AES_DECRYPT(AES_ENCRYPT('text', SHA1('My secret passphrase')), SHA1('My secret passphrase')) as denc Result: enc : 3278167d9d630327c74d83067964c9b6 denc: 74657874 text...

Encrypt NSString (NOT NSData) in iOS -> send to PHP server -> let PHP server decrypt it?

php,ios,objective-c,encryption,aes
I know there is openSSL but I just want to use encryption. Here is exactly what I wish to do. 1) encrypt NSString in xcode(objective-c) with AES-128 or whatever encryption method that works 2) send the encrypted NSString to PHP server using POST method. The parameter that will be sent...

How to use Bouncycastle's CMac

java,aes,bouncycastle
I'm trying to use BouncyCastle's CMac implementation but apparently I'm doing it wrong. At least the following unit test (based on RFC 5297 test vectors) fails: @Test public void testCMacOfZeros() { byte[] key = {(byte) 0xff, (byte) 0xfe, (byte) 0xfd, (byte) 0xfc, // (byte) 0xfb, (byte) 0xfa, (byte) 0xf9, (byte)...

How to decrypt a XBEE S1 packet encrypted knowing the key?

encryption,aes,xbee
I sniffed a XBEE S1 packet and it's normally a full 802.15.4 packet. The AES encryption is enable on my module xbee s1 and I know the key. What is the algorithm to decrypt the data payload ? Normally, in a 802.15.4 packet, there is the flag "Security level" that...

Produce the ECB penguin with AES in python

python,image,encryption,aes,ecb
I want to encrypt data in an image but the resulting ciphertext to still be a valid image. I encrypt the image with AES in python and then, I replace header in the files, but windows can't open the encrypted image. Code def encrypt_file(self, in_filename, out_filename): filesize = os.path.getsize(in_filename) iv...

Using Salt in AES in C# and PHP

c#,php,encryption,mono,aes
I'm trying to encode and decode a string using AES. At the moment, I'm encoding the string in Mono C# using the highest-rated answer here, because System.Security.Crytpography.Aes is not available in Mono. However, this implementation uses a Salt, and the PHP method I'm using to decrypt it does not take...

AES encryption in c# and compare result in file level

c#,encryption,file-io,aes
new to AES, I visited several threads about it, ex: examples of Dan Esparza, Zeeshan Amber at this thread Simple encryption algorithm in c#.net , and smdrager at Simple encryption algorithm in c#.net I tried to use some examples in my case, but I found something incorrect, let me explain:...

Smartcard PKCS11 AES Key Gen Failure

python,aes,smartcard,pkcs11
I am attempting to create an AES 256 key on an ACOS5-64 smartcard and OMNIKEY 3121 card reader, using PKCS11 in python (using the PyKCS11 library). So far, all the "standard" operations seem to work with regards to asymmetric crypto. I have run plenty of code samples and pkcs11-tool commands,...

AES 256 with PKCS7 padding encoded data have half ECB and half CBC block

php,objective-c,aes,mcrypt,commoncrypto
Im trying to decode data in php returned from server: I know data AES 256 decoded and have PKCS7 padding but cant figure out which block mode it use here is my php function: public function decode($data) { //AES decode $iv = mcrypt_create_iv(GEServerConnection::FBENCRYPT_BLOCK_SIZE, MCRYPT_RAND); $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->cryptKey, base64_decode($data), MCRYPT_MODE_ECB,...

Symmetric encryption issue between a .Net application and a Java application

java,.net,encryption,aes,encryption-symmetric
I am integrating with a .Net application which uses Symmetric encryption. My application is on Java. Following is the .Net code which was shared by the team which uses the Symmetric encryption; public static string SymmetricEncrypt<T>(string value, string PrivateKey, string SALT_STRING) where T : SymmetricAlgorithm, new() { PasswordDeriveBytes rgb =...

confusion on using RNCryptor for iOS to post to PHP-based server

php,ios,objective-c,encryption,aes
Based on this link: https://github.com/RNCryptor/RNCryptor I've learned that this is a basic method to encrypt NSData NSData *data = [@"Data" dataUsingEncoding:NSUTF8StringEncoding]; NSError *error; NSData *encryptedData = [RNEncryptor encryptData:data withSettings:kRNCryptorAES256Settings password:aPassword error:&error]; And here is my code doing POST request to PHP-based server. NSString *parameter = [NSString stringWithFormat:@"userid=%@&password=%@",useridStr, passwordStr]; NSData *parameterData...

How to add HMAC to CryptoJS AES encryption?

javascript,encryption,cryptography,aes,cryptojs
CryptoJS's convenience function CryptoJS.AES.encrypt("some plaintext", "password") doesn't seem to do any authentication. I see CryptoJS provides an HMAC class, but I'm confused about how to use this to encrypt-then-authenticate. I searched around for tutorials and other questions but couldn't find any. How would I add authentication using the above CryptoJS...

Golang AES StreamReader encryption - Example omits any authentication of the encrypted data

encryption,go,aes,encryption-symmetric
Finally I am posting my first question on StackOverflow. I'm using this site for years now and I always found great answers to all my questions :) I am implementing a file encryption background daemon which is based on the official Golang cipher example: func ExampleStreamReader() { key := []byte("example...

AES-functions always reply with empty results

.net,vb.net,encryption,aes,rijndael
today I've got a question about my current Visual Basic project I'm going for. My intention is to serve one or more encrypted Configuration-files for my program in the same directory where the executable is placed in. Because most likely the (en/de)cryption will be processed twice (username and password), I...

Legacy encryption in Java and decryption in PHP

java,php,encryption,aes
I'm trying to encrypt a string using PHP with same result of a legacy Java code. Java code: public static SecretKeySpec createSecretKey(String mKey) { SecretKeySpec secretKey = null; MessageDigest sha = null; try { byte[] key = mKey.getBytes("UTF-8"); sha = MessageDigest.getInstance("SHA-1"); key = sha.digest(key); key = Arrays.copyOf(key, 16); // use...

AES-256-GCM mode decryption fails in php

php,encryption,openssl,aes,aes-gcm
Here's my code: <?php $secret="This is a secret message."; $key="Secret key."; $iv=openssl_random_pseudo_bytes(12); $method="aes-256-gcm"; $encrypted=openssl_encrypt($secret,$method,$key,false,$iv); $decrypted=openssl_decrypt($encrypted,$method,$key,false,$iv); echo $encrypted; echo "<br>"; echo $decrypted; ?> I've got the encrypted message, but the decryption gives no result or error message. The same code is working with another method, like aes-256-cbc....

C# Aes ecb pkcs5pad

c#,php,encryption,aes
i need a AES function to encrypt/decrypt with model ecb, PKCS5Padding using an symmetric key(128 bits created with AES parameters) but I'm having some problems with this since im noob in c# in php is approximate to this and i need create in ASP.net(c#): pkcs5 pading: function pkcs5_pad($text, $blocksize) {...

encrypting AES128-CBC on mbed microcontroller(c++) and decrypting AES128-CBC in nodejs

c++,node.js,cryptography,aes,mbed
I am receiving "Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt" when I try to decrypt a string on the nodejs side. I do know for better security I should use a random IV and always change the IV for every new encryption and I should also implement authentication, but for the sake...

What are the different ways of generating a key for encription

php,encryption,aes,symmetric-key
I am using aes256 with php to encrypt data. In the various documents I see various ways to generate a key, Like: $key = pack('H*', "bcb04b7e103a0cd8b54763051cef08bc55abe029fdebae5e1d417e2ffb2a00a3"); Or $Key = "what ever, plain string"; Or $Key = "123456789abcdef";//128bit What is the point of the first example, as opposed to the others?...

Data is not saved into database or not properly decrypted after adding MCrypt's AES-CBC encryption

php,mysql,encryption,aes,mcrypt
I'm having an issue with an encryption script I wrote. I have hundreds of inputs, and therefore I used a bucket sorting algorithm as an "in-script" database in order to avoid the hassle of dealing with hundreds of MySQL columns, not to mention it saves on code space. The data...

Ruby OpenSSL AES-128-CTR

ruby,openssl,cryptography,aes
I can't figure out what I am doing wrong here trying to decrypt a string of hex values with a given key using ruby's OpenSSL cipher AES-128-CTR. I am using the gem hex_string to convert my hex to bytes ctrkey = "36f18357be4dbd77f050515c73fcf9f2" ciphertext3 = "69dda8455c7dd4254bf353b773304eec0ec7702330098ce7f7520d1cbbb20fc3\ 88d1b0adb5054dbd7370849dbf0b88d393f252e764f1f5f7ad97ef79d59ce29f5f51eeca32eabedd9afa9329" cipher2 = OpenSSL::Cipher.new('AES-128-CTR') cipher2.decrypt...

Encrypting (large) files in PHP with openSSL

php,file,encryption,aes,php-openssl
I'm trying to encrypt (big) files in PHP using AES and have looked into using Mcrypt and OpenSSL, the problem is all solutions I have found so far only encrypt strings, and the files I'm trying to encrypt would trigger the max memory limit for PHP (which unfortunately can't be...

SQL LOWER function not working with encryption

mysql,sql,encryption,aes,querying
I have a problem with an SQL query where the LOWER function does not work when I am decrypting with AES. This is a cut down version of the query: SELECT LOWER(AES_DECRYPT(forename, 'encryptionkey')) forename FROM tenant; This will still return with capital letters in the result. Does anyone know how...

What type of encryption do I need?

encryption,aes,des,encryption-symmetric
Ok, the original task is to track users among 2 "friendly" web-sites who are able to share users cookies (lets say, I have example.com and my friend has mysite.com and also he has a domain simple.example.com so he can set cookies on .example.com). To track users activity we want to...

AES encrypt/decrypt text

c++,algorithm,encryption,cryptography,aes
I have a text which contains email, username and password and I encrypt it using AES algorithm. It seems to be ok while I am encrypting, but when it goes to decrypting, only some part (fist 48bytes = 3x 16byte chunks) are ok, but the rest is just some garbage....

AES128 encryption in Xcode and decrypt in PHP succeeds and fails depending on key value

php,ios,xcode,encryption,aes
I followed steps at https://tharindufit.wordpress.com/2011/12/15/aes128-encryption-in-ios-and-decryption-in-php/ to develop client encryption in Xcode and server decryption in PHP. I generated a aes-128-ecb key at https://asecuritysite.com/encryption/keygen. My question is: If I make the key a short string like "key", the PHP decryption works; but if I use a key generated by the...

AES 256 and Base64 Encrypted string works on iOS 8 but truncated on iOS 7

php,ios,encryption,aes
One of my app needs to download a database with the content encrypted in AES 256. So I've used on server side phpAES to encode the strings in AES CBC with an IV. On the iOS side I'm using FBEncryptor to decrypt the string. This is the code on the...

AES encryption/decryption iOs and .Net

ios,objective-c,.net,encryption,aes
I used CocoaSecurity and RNCryptor to encrypt NSString on iOs app, and on the server side (.NET) tried to decrypt it using one of the many function found on the web, but no luck. Also AES decryption online tools, fail to decrypt. Can somebody provides a working example of NSString...

How unsafe is revealing a part of AES cryptographic key?

cryptography,aes
Is it crucial for AES to keep whole key in secret or it is possible, although not desirable to reveal for example first 4 chars of 16-char-long key? I want to use a part of key as a generator for a random number and curious what will happen if that...

how to 'Zero out' from memory an AES SecretKeySpec Key in Java

java,memory,encryption,aes,symmetric-key
I am using Java AES encryption using SecretKeySpec(byte[] key, String algorithm) to generate a Key object. After I encrypt something, I want to remove the Key from memory. I can remove all references to the Key, but that does not guarantee that the key is not floating somewhere in memory....

Part of Decrypt non-sense

java,android,encryption,aes
I am working a chat in android, here I am using the next methods for key generation, encrypt and decrypt messages. The problem is that when I send a message for example "hola" in the other side I get "holgAAAAAAAAAAAAAAA". Could you help to fix this?. private byte[] K; public...

Problems with SJCL “Cannot read property 'replace' of undefined”

javascript,encryption,aes,sjcl
Using Sjcl i try to write a little service sending and receiving encrypted data from my javascript application. Sadly, the sjcl documentation is lacking information on how to process their AES encrypted data. Their encrypt method returns an object containing serveral attributes of which i can only guess what is...

Aes Decrypt goes wrong when using GET - PHP

php,aes
Aes Decrypt goes wrong when I using GET method. resetPassword.php?em=/7tI2cvhU31O0v3Dr+YGtpgPaxKVB6InHeriyZhxyNk= this is what I send to php file, if I print the: $_GET['em'] the page show me this output: /7tI2cvhU31O0v3Dr+YGtpgPaxKVB6InHeriyZhxyNk= this is ok, if I call to decrypt function like: fnDecrypt($_GET['em'], $AESPassword) I get this output: ����H�M�.�Ҭ�;��&4o�r0�V`jڔݖ� if I call...

Java AES encryption/decryption procedure

java,encryption,cryptography,aes
I want to learn the basics of AES encryption so I started to make a very simple Java program. The program loads a text file to a string and asks key from the user. After this the program uses AES to encrypt it to another new text file and prints...

Encrypt and Decrypt by AES algorithm in both python and android

android,python,encryption,encoding,aes
I have python and android code for AES encryption. When I encrypt a text in android, it decrypt on python successfully but it can’t decrypt in android side. Do anyone have an idea? Python code : import base64 import hashlib from Crypto import Random from Crypto.Cipher import AES class AESCipher:...

Encrypt file in python with aes

python,encryption,aes
I want to encrypt and decrypt a file (any type of file) using aes 128 in cbc mode in python. I am quite new to cryptography and i have tried some tutorials but all work only on texts, and i need it for files. Could anyone suggest me a solution?...

CCCrypt working with pieces of files AES CBC: garbage to end of files on encryption-decryption cycle

ios,swift,aes,encryption-symmetric
Although I was able to get data encryption and decryption (AES128CBC) working easily with CCCrypt based on some of the great examples of Zaph and others here, I have had two strange problems with CCCrypt when working with encrypting/decrypting files. 1) Upon encrypting and then decrypting a file, I am...

AES vs PBEWithSHA256And256BitAES

java,encryption,cryptography,aes
I need to encrypt some data with a password. It has to be a variation of AES with a 256bit key. I searched a while on the web and came up with this two alogrithms. Now I do not know, which one to choose, cause I do not know, which...

Encrypt AES key?

encryption,aes
Consider this scenario: Key1 = random key Key2 = random key CombinedKey = Key1.encrypt (Key2) Input = "test" Step1 = CombinedKey.encrypt (Input) Step2 = key2.decrypt (step1) Result = key1.decrypt (step2) Is Result == "test" if the encryption type is AES? Or for any other encryption algorythm?...

Preferences & javax.crypto.BadPaddingException: Given final block not properly padded

java,encryption,aes,preferences
I've been staring at this code for hours, and I must be missing something silly. As a result someone's help here is greatly appreciated. Below is example code, the simplest I could get it to repro this issue. The code works fine the first time it runs, but then after...

vb.net AES decryption returns “data is incomplete block”

vb.net,encryption,cryptography,aes
I'm aware of the other thread on this issue (AES decryption error " The input data is not a complete block." Error vb.net), but I'm either not implementing the solutions offered there correctly, or something about my particular variant of this issue isn't covered by those solutions. In any event...

Symmetric encryption (AES) in Apache Thrift

java,python,encryption,aes,thrift
I have two applications that interact using Thrift. They share the same secret key and I need to encrypt their messages. It makes sense to use symmetric algorithm (AES, for example), but I haven't found any library to do this. So I made a research and see following options: Use...

Why does node.js's crypto module give a different result than Java's Cipher class for AES encryption?

java,node.js,encryption,aes
I'm trying to understand why encrypted data changes when using Java or Node.js to encrypt it, I need to adapt node.js code to make it return exactly the same encrypted data that I have on Java. (Note that I cannot modify the java snippet) Node.js Implementation: var crypto = require('crypto');...

Encrypting data with forgejs on the client side, and decrypting with ruby

javascript,ruby,encryption,aes
For a given project, I'm looking to encrypt a piece of data with AES 256, and then RSA encrypt the key. I've been using Forge and the Encryptor gem in ruby, and i can't seem get matching encryption values: var key = 'strengthstrengthstrengthstrength'; var iv = 'cakecakecakecakecakecakecakecake'; var cipher =...

SagePay Upgrade 2.22 to 3.0 No Crypt Field

curl,aes,protocols,crypt,sagepay
I've been asked to assist upgrading a SagePay custom payment implementation from protocol v2.22 to protocol v3.0. I'm trying to follow the instructions on this page: https://www.sagepay.co.uk/support/12/36/upgrading-from-2-22-to-3-00-a-brief-overview The first problem I have is that nowhere in the existing code is there a 'Crypt' field. In fact the 'data' is sent...