aes

C# AES Decryption code

荒凉一梦 提交于 2019-12-08 10:21:43
问题 I have the code for string encryption/decryption with AES algorithm. Encryption works fine as expected but I could not get correct plain text when I decrypt it back. There must be something wrong in the decryption code. I have copied the code below. Please help with this. Thanks. Below is the encryption and Decryption code. public static class EncryptionHelper { private static int BlockSize = 16; private static byte[] Key { get { byte[] hash = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(

The specified initialization vector (IV) does not match the block size for this algorithm

◇◆丶佛笑我妖孽 提交于 2019-12-08 10:14:04
问题 I'm trying to adapt an example RinjaelManaged encryption class (see: Encrypting & Decrypting a String in C#) to instead use the AesCryptoServiceProvider so it can run on computers set to use only FIPS compliant algorithms. However it seems it's not as simple as swapping out the class names as I now get an error about the length of the Initialization Vector. I realise there are several questions about this already but I've been unsuccessful with trying to use the answers from other questions

C# AES-128 CFB Error [duplicate]

若如初见. 提交于 2019-12-08 09:30:44
问题 This question already has answers here : C# AES: Encrypt a file causes “Length of the data to encrypt is invalid.” error (3 answers) Closed 4 years ago . I currently set up RijndaelManaged this way (the IV and Key are the same due to how the server handles the encryption). The server also uses CFB8 for the Mode, did I set this up correctly? public static RijndaelManaged GenerateAES(byte[] key) { RijndaelManaged cipher = new RijndaelManaged(); cipher.Mode = CipherMode.CFB; cipher.Padding =

SSLSocket and AES Encryption

不羁岁月 提交于 2019-12-08 09:23:32
问题 We need to use AES encryption for client server communication, so when I enable the Cipher Suite TLS_DHE_RSA_WITH_AES_128_CBC_SHA on a SSLServetSocket ( using Java 6) and run the program, i am getting below exception No available certificate or key corresponds to the SSL cipher suites which are enabled My question is can we AES encryption over SSLSocket or it needs to be a regular socket. If we can't use it, can anyone please provide me an example of client server communication using AES

Can't use 256-bits counter in AES.MODE_CTR cipher in python

眉间皱痕 提交于 2019-12-08 08:55:47
问题 guys. I use crypto library for AES encryption and decryption. AES-128 works perfect: ctr = Counter.new(128) key = os.urandom(16) obj = AES.new(key, AES.MODE_CTR, counter=ctr) But when I change 128 to 256, and 16 to 32 error occurs: ValueError: unsupported format character 'b' (0x62) at index 29 Could you help me, any suggestions? 回答1: The counter size is the same as the block size of the block cipher. The block size and key size of a cipher are not directly related. Now AES-256 has a key size

openssl- decrypting a base64 string with a key and IV

笑着哭i 提交于 2019-12-08 08:34:54
问题 I'm trying to decrypt a base64 string which has been encrypted with aes256 in openssl. I was given the session key and IV, which were encrypted with my key. I converted them to hexadecimal so that I can use the following openssl command: openssl enc -d -aes256 -iv iv.hex -K sessionkey.hex -in message.b64 -out message.txt I get the error saying the IV is a non-hex value. I started out with IV and session key in base64, which was encrypted with my key. So I did the following: //convert base64

AES-256-CBC encryption in PHP and decryption in Node.js

和自甴很熟 提交于 2019-12-08 08:21:48
问题 my problem is that I encode a string in PHP with the m_crypt module in aes-256-cbc with base64 like this: function encrypt($data) { if(32 !== strlen($this->secret)) $this->secret = hash('SHA256', $this->secret, true); $padding = 16 - (strlen($data) % 16); $data .= str_repeat(chr($padding), $padding); $encrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->secret, $data, MCRYPT_MODE_CBC, str_repeat("\0", 16)); return base64_encode($encrypt); } Where $this->secret is a 32-bit aes key and $data is

Convert C# to Python using AES/CBC/NoPadding

寵の児 提交于 2019-12-08 08:05:59
问题 I'm trying to convert this C# code to Python (2.7). The problem is that the result of the decryption is wrong with the python code. IV and key is correct. I found many subjects that talk about Python and C# but i didn't found an answer. C# encryption: class Tracer { private static readonly int BlockBitSize = 128; private static readonly int KeyBitSize = 256; internal static byte[] In(byte[] plainBytes, byte[] uid) { using (var sha = new SHA512Managed()) { var hash = sha.ComputeHash(uid);

Python 3.2 - Symétric AES Crypto in CBC mode - advices requested

徘徊边缘 提交于 2019-12-08 06:09:14
问题 My goal is to setup simple encryption with python 3.x, so I searched the web this weekend to get informations about RSA / AES and so on ... Actually, things that may look like a possibility to encrypt text data for transmission in a reasonable secure way .. without paranoia either, I'm not an expert just want to make sure that the stuff is pretty hard to read without the key ! Honestly, I do not know much about cryptography. After several hours of searching and collecting information and

Aes decryptor gives empty string

不羁岁月 提交于 2019-12-08 06:05:33
问题 I have problem with AES encryption/decryption. The commented code worked but sometimes gave error "padding is invalid and cannot be removed" so I changed it as it is explained here Padding is invalid and cannot be removed Exception while decrypting string using "AesManaged" C# but when I tried it the code below during decryption gives an empty string. I don't know where I make mistake. The two static functions bytesToString and stringToBytes has nothing to do with encryption and I use them in