aes

AES encryption, what are public and private keys?

Deadly 提交于 2019-11-28 16:13:57
In AES encryption (.net framework), how are the public and private keys used? Are the public and private keys combined to form a full key, and then the algorithm uses the public + private key to encrypt the data? (simplified keys used below for example purposes) e.g. public key = 12345 private key = 67890 so the key used when generating the encryption result is: 1234567890 As others have said, AES is a symmetric algorithm ( private-key cryptography ). This involves a single key which is a shared secret between the sender and recipient. An analogy is a locked mailbox without a mail slot.

AES 256 Encryption: public and private key how can I generate and use it .net [closed]

微笑、不失礼 提交于 2019-11-28 16:03:15
问题 Regarding AES 256 Encryption: What is the public and private key? How can I generate these two keys? How can I use the public to encrypt the data? How can I use the private to decrypt the data? 回答1: In .Net, you can create your key pair like this: public static Tuple<string, string> CreateKeyPair() { CspParameters cspParams = new CspParameters { ProviderType = 1 }; RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(1024, cspParams); string publicKey = Convert.ToBase64String

Storing passwords with Node.js and MongoDB

末鹿安然 提交于 2019-11-28 15:16:34
问题 I'm looking for some examples of how to securely store passwords and other sensitive data using node.js and mongodb. I want everything to use a unique salt that I will store along side the hash in the mongo document. For authentication do I have to just salt and encrypt the input and match it to a stored hash? Should I ever need to decrypt this data and if so how should I do it? How are the private keys, or even salting methods securely stored on the server? I've heard the AES and Blowfish

How can I encrypt with AES in C# so I can decrypt it in PHP?

自闭症网瘾萝莉.ら 提交于 2019-11-28 14:40:42
I've found a few answers to Encrypt in PHP, and Decrypt in C#, but as yet have been unable to reverse the process... The background is I want to: In C#: AES encrypt a file's contents. Upload the data (likely via http via POST) to a server. In PHP: Receive and save the file. And in PHP (at a later date): Decrypt the file. I specifically want to encrypt it outside of using SSL/TLS (though I might have to do this as well), as I need to know the file remains encrypted (and decryptable!) when stored on the server. To encrypt in C# I'm using: Rijndael RijndaelAlg = Rijndael.Create(); RijndaelAlg

Having trouble decrypting a well-formed cipher text using Crypto++

好久不见. 提交于 2019-11-28 14:10:27
Background I've been struggling with decrypting an apparently well-formed cipher text for about a day. Assume we've got the following hex-encoded cipher text which contains exactly 160 characters thereby having 80 bytes. QString c = "1BFAC407AF0D440A2D6176C0B5D125AA96088490299AC18C74623C0EF1BB1372E554FC4150A8066220E943697BE2491D8AE13AA036B298425AC510A8A917D59EBB69708B9040AB3A84C63043EAD4AB07"; QString k = CryptoUtils::hexEncode("abc"); QString p = CryptoUtils::decrypt(c, k); qDebug() << p; Provided we're using AES 256, AFAIK, the key must be of length 32 bytes and cipher text of a length of

Does AES_cbc_encrypt add padding?

微笑、不失礼 提交于 2019-11-28 14:08:51
Consider the following snippet of C++ code: #include <iostream> #include <openssl/aes.h> #define AES_KEY_LENGTH 32 using namespace std; int main() { AES_KEY encryption_key; AES_KEY decryption_key; unsigned char key[AES_KEY_LENGTH] = {'t', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't'}; unsigned char iv[AES_BLOCK_SIZE] = {'t', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't', 't', 'e', 's', 't'}; unsigned char iv_enc[AES_BLOCK_SIZE]; unsigned char iv_dec[AES_BLOCK_SIZE]; memcpy(iv

AES encryption in Node.js to match expected decryption in Python

风格不统一 提交于 2019-11-28 13:36:32
问题 I have the following Python script for decryption: from Crypto.Cipher import AES shared_secret = raw_input('Enter crypted_shared_secret: ').strip() cipher = AES.new(shared_secret.decode('base64'), AES.MODE_ECB) blob = raw_input('Enter crypted_blob: ').strip() plain = cipher.decrypt(blob.decode('base64')) print(plain) I'm trying to generate the values that would produce the original blob using that script, using Node. Here is my attempt: const Crypto = require('crypto'); var shared_secret =

Encrypting (large) files in PHP with openSSL

夙愿已清 提交于 2019-11-28 12:34:09
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 set higher), how would I go about achieving this? You could use CBC encryption using Mcrypt and then encrypt a segment of data at a time. Make sure that the segment is x times the block size of the used cipher (e.g. 16 bytes for AES). Encrypt the segment and take the last block of the generated ciphertext and use it as

Part II: How to make Ruby AES-256-CBC and PHP MCRYPT_RIJNDAEL_128 play well together

房东的猫 提交于 2019-11-28 12:06:57
This question is a continuation of my last one, regarding How to make Ruby AES-256-CBC and PHP MCRYPT_RIJNDAEL_128 play well together . I've got that working now, but I'm still struggling to go the other direction. The PHP generated cryptogram appears to have all the information that was provided, but I cannot get the Ruby code to decrypt it without error. Here's the PHP code I'm using to generate the cryptogram: $cleartext = "Who's the clever boy?"; $key = base64_decode("6sEwMG/aKdBk5Fa2rR6vVw==\n"); $iv = base64_decode("vCkaypm5tPmtP3TF7aWrug=="); $cryptogram = mcrypt_encrypt(MCRYPT_RIJNDAEL

C# AES: Encrypt a file causes “Length of the data to encrypt is invalid.” error

筅森魡賤 提交于 2019-11-28 11:47:40
I have a PDF File. When I want to encrypt it using codes below the Length of the data to encrypt is invalid. error occurred: string inputFile = @"C:\sample.pdf"; string outputFile = @"C:\sample_enc.pdf"; try { using (RijndaelManaged aes = new RijndaelManaged()) { byte[] key = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; byte[] iv = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; aes.Key = key; aes.IV = iv; aes.Mode = CipherMode.CFB; aes.Padding = PaddingMode.None; aes.KeySize = 128; aes.BlockSize = 128; using (FileStream fsCrypt = new FileStream(outputFile, FileMode