rijndael

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

故事扮演 提交于 2019-11-30 04:31:49
I am working on a base encryption method. I am using RijndaelManaged. I got this code from somewhere a long time ago, but can't remember where. I had my code working before, but something changed and I cannot quite figure it out. When I run my code, I get the following error; Specified initialization vector (IV) does not match the block size for this algorithm. Here is my code: string textToEncrypt = "TEST STRING"; int keySize = 256; string hashAlgorithm = "SHA1"; string passPhrase = "AH!PSB0%FGHR$"; string saltValue = "LRT%YUR#VBNL@1"; string initVector = "HR$2pIjHR$2pIj"; byte[]

How to call use .NET RijndaelManaged from native COM?

随声附和 提交于 2019-11-29 11:59:16
Can anyone give example usage for using System.Security.Cryptography.RijndaelManaged from native Win32 using COM? Here is a functional example of how to use .NET's System.Security.Cryptography.SHA256Managed Note : This is an example of how to call SHA256Managed, and not RijndaelManaged**. i show this code to introduce some of the tricky concepts of calling COM objects with early and late-binding, and to show that calling .NET objects with COM Callable Wrappers is possible. Some people might throw up that hands when hearing i want to mix .NET and Win32 COM. Note: The language is Delphi (which

Rewrite Rijndael 256 C# Encryption Code in PHP

久未见 提交于 2019-11-29 06:06:21
I have an encryption/decryption algorithm written in C# - I need to be able to produce the same encryption in PHP so I can send the encrypted text over HTTP to be decrypted on the C# side. Here is the C# code for the encryption. this.m_plainText = string.Empty; this.m_passPhrase = "passpharse"; this.m_saltValue = "saltvalue"; this.m_hashAlgorithm = "SHA1"; this.m_passwordIterations = 2; this.m_initVector = "1a2b3c4d5e6f7g8h"; this.m_keySize = 256; public string Encrypt() { string plainText = this.m_plainText; string passPhrase = this.m_passPhrase; string saltValue = this.m_saltValue; string

PHP to Delphi and back Encryption-Decryption using Rijndael

家住魔仙堡 提交于 2019-11-29 05:19:39
I have problems with decrypting strings sent from PHP to Delphi using the rijndael cipher. I'm using mcrypt on the PHP side and DCP_rijndael on the Delphi side. At the moment I have the below code. PHP: function encRJ($key, $iv, $data) { $r = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, $iv); $r = base64_encode($r); return $r; } And in Delphi: function decRJ(Data: string; Key: string; IV: string): string; var ciph: TDCP_rijndael; begin Data := Base64DecodeStr(Data); ciph:= TDCP_rijndael.Create(Self); ciph.Init(Key[1], 256, @IV[1]); ciph.DecryptCBC(Data[1], Data[1], Length

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

你说的曾经没有我的故事 提交于 2019-11-29 01:46:56
问题 I am working on a base encryption method. I am using RijndaelManaged. I got this code from somewhere a long time ago, but can't remember where. I had my code working before, but something changed and I cannot quite figure it out. When I run my code, I get the following error; Specified initialization vector (IV) does not match the block size for this algorithm. Here is my code: string textToEncrypt = "TEST STRING"; int keySize = 256; string hashAlgorithm = "SHA1"; string passPhrase = "AH!PSB0

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

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(

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

How to encrypt in VBScript using AES?

丶灬走出姿态 提交于 2019-11-28 09:16:57
I am looking to encrypt some data using Rijndael/AES in VBScript using a specific key and IV value. Are there any good function libraries or COM components that would be good to use? I looked at CAPICOM ; it allows a passphrase only, and won't allow setting specific key and IV values. Old question- that really never gets old! One way is to declare encryption classes within vbscript, without needing external added COM objects or wrapper. The following example takes a string, encrypts and decrypts using Rijndael managed class: '----------------------------------------------------- Dim obj,arr,i

How to generate Rijndael KEY and IV using a passphrase?

懵懂的女人 提交于 2019-11-27 17:52:30
How to generate Rijndael KEY and IV using a passphrase? The key length must be in 256 bits. Pan Pizza This is plug and play code that I found on internet. It just works: using System.IO; using System.Security.Cryptography; private static readonly byte[] SALT = new byte[] { 0x26, 0xdc, 0xff, 0x00, 0xad, 0xed, 0x7a, 0xee, 0xc5, 0xfe, 0x07, 0xaf, 0x4d, 0x08, 0x22, 0x3c }; public static byte[] Encrypt(byte[] plain, string password) { MemoryStream memoryStream; CryptoStream cryptoStream; Rijndael rijndael = Rijndael.Create(); Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(password, SALT); rijndael