java,encryption,3des,tripledes
You can get the IV from the cipher: ecipher.getIV(); The problem is that the IV is generated during init. Since you init in the constructor you would run into the problem of using the same IV for every encryption of different ciphertexts. It's always best to generate a new Cipher...
The usage byte[] fileByteArray = new byte[fileInputStream.available()]; is specifically warned against in the Javadoc: " It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream." Files should be processed a record or a buffer at...
PHP code: $key = "6702BC24DD0527E7"; $key = md5($key,TRUE); $key .= substr($key,0,8); The C# code is "ok" as it is. "ok" is a big word here. I would probably use SHA256 and trim it to 24 bytes: C#: SHA256Managed sha256 = new SHA256Managed(); keyArray = sha256.ComputeHash(UTF8Encoding.UTF8.GetBytes(key)); Array.Resize(ref keyArray, 24); //Always release...
i Found my problem. It was the way i was reading the key. i created this method for converting hex string into NSData: + (NSData *)dataFromHexString: (NSString *) hex { const char *chars = [hex UTF8String]; int i = 0, len = hex.length; NSMutableData *data = [NSMutableData dataWithCapacity:len / 2];...
You're using the original (encryptor) tripledes instance, rather than the decryptor instance tripledes1 to decrypt.
smartcard,javacard,3des,parity,globalplatform
You are only flipping the parity bit which is not used nor checked by the card (or software). Which means the outcome of ciphers is the same, yes.
ios,swift,encryption,3des,tripledes
It is probably a different padding being used. DES has a block size of 8 byte. So the first block is 12345678 and the second block is 9. Since DES is a block cipher the plaintext must be padded to the next block size. The online tool probably uses zero...
c#,vb6-migration,encryption-symmetric,3des
There's actually a very simple solution, although it's not at all obvious. You have a block of code which says "If this data isn't exactly a multiple of 8, pad it." However, this is changing the value you're encrypting, so you get a different result. Simply remove the whole if(streamToEncrypt.Length.Dump("Length")...
The block size of DES is 64-bit or 8 bytes. When the plaintext size is a multiple of the plaintext the padding used will add another block of data to the plaintext filled with 0x08. This is how PKCS#5/PKCS#7 padding works. It seems that your HSM expects that no padding...
You could use token as a vector on TripleDESCryptoServiceProvider, together with the key. ICryptoTransform cTransform = tdes.CreateEncryptor(key, token); ...
PHP mcrypt doesn't handle PKCS5 padding, instead it uses simple zero padding. This is why you get different results compared to Python libs which use PKCS5 padding. Here a workaround to get PKCS5 padding in PHP: https://chrismckee.co.uk/handling-tripledes-ecb-pkcs5padding-php/ EDIT I confirm it works with this guy's lib: $key = '111111111111111111111111'; $x...