tripledes

TripleDES in CFB mode, C# and Crypto++ differs

旧时模样 提交于 2019-12-01 21:46:32
Here is my problem: I've got a legacy code in C++ (using crypto++ v5.6.1) and I develop a new one in C# (.NET 3.5 using System.Security.Cryptography). I can't change the C++ code, but I need to be able to decrypt data previously encrypted and previous applications has to be able to decrypt the data I will crypt with my new C# code. The algorithm used is TripleDES with CFB cipher mode in both cases, but in the end, the encrypted data are not the same, the number of bytes are identical as well as the first byte, but apart from that all other bytes are different. The padding is manually done

TripleDES Encrypting in C# and PHP not coming out the same (PKCS7, ECB)?

梦想与她 提交于 2019-12-01 09:06:42
I've spent a couple hours now trying to figure this out, but I just can't get it to work. I've got a C# encryption routine that I need to match in php. I can't change the C# version, that's not an option (3rd party is firm on this). Here's the C# code: //In C# // Console.WriteLine(ApiEncode("testing", "56dsfkj3kj23asdf83kseegflkj43458afdl")); // Results in: // XvHbR/CsLTo= public static string ApiEncode(string data, string secret) { byte[] clear; var encoding = new UTF8Encoding(); var md5 = new MD5CryptoServiceProvider(); byte[] key = md5.ComputeHash(encoding.GetBytes(secret));

TRIPLE DES encryption/decryption using php

别说谁变了你拦得住时间么 提交于 2019-12-01 07:38:07
问题 I have this TRIPLE DES ENCRYPTION CODE IN PHP $encryption_key = "CE51E06875F7D964"; $data='tokenNo=test&securityCode=111' ; echo $desEncryptedData = encryptText_3des($data, $encryption_key);//outputs 3des encrypted data function encryptText_3des($plainText, $key) { $key = hash("md5", $key, TRUE); for ($x=0;$x<8;$x++) { $key = $key.substr($key, $x, 1); } $padded = pkcs5_pad($plainText, mcrypt_get_block_size(MCRYPT_3DES, MCRYPT_MODE_CBC)); $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_3DES,

TripleDES Encrypting in C# and PHP not coming out the same (PKCS7, ECB)?

血红的双手。 提交于 2019-12-01 06:20:41
问题 I've spent a couple hours now trying to figure this out, but I just can't get it to work. I've got a C# encryption routine that I need to match in php. I can't change the C# version, that's not an option (3rd party is firm on this). Here's the C# code: //In C# // Console.WriteLine(ApiEncode("testing", "56dsfkj3kj23asdf83kseegflkj43458afdl")); // Results in: // XvHbR/CsLTo= public static string ApiEncode(string data, string secret) { byte[] clear; var encoding = new UTF8Encoding(); var md5 =

MACTripleDES in PHP

China☆狼群 提交于 2019-11-30 21:14:47
I am trying to get a MAC TripleDES equivalent of the C# MACTripleDES class. I have tried following mcrypt() , but that is just encoding in TripleDES. I need to get an equivalent MACTripleDES string as the one that is generated in C# to authenticate a message. I have also looked at PHP's hash_hmac() function but it does not give the option of generating a MAC with TripleDES I'm not sure since Microsoft didn't bother to say what standard their class conforms to, but I suspect that this NIST document is what the Microsoft class is computing, only using triple DES in place of DES. I guess you will

Triple DES decryption invalid key with 16 bytes

纵饮孤独 提交于 2019-11-30 10:39:23
I have an android project in which am getting an Triple DES encrypted piece of text from my web services. I need to Triple DES decrypt. However, I am getting invalid key exceptions. My key is converted to HEX format and I got an error: W/System.err﹕ java.security.InvalidKeyException: DES key too long - should be 8 bytes I found here a forum explaining that hex may cause issue "DES keys are 56 bits normally packaged in 8 bytes so the chances are that the 16 bytes/characters they have given you are the hex encoded bytes of the key. You can get a hex decoder" So I converted my hex string to a

MACTripleDES in PHP

南楼画角 提交于 2019-11-30 05:43:36
问题 I am trying to get a MAC TripleDES equivalent of the C# MACTripleDES class. I have tried following mcrypt(), but that is just encoding in TripleDES. I need to get an equivalent MACTripleDES string as the one that is generated in C# to authenticate a message. I have also looked at PHP's hash_hmac() function but it does not give the option of generating a MAC with TripleDES 回答1: I'm not sure since Microsoft didn't bother to say what standard their class conforms to, but I suspect that this NIST

TripleDES in Perl/PHP/ColdFusion

隐身守侯 提交于 2019-11-28 09:59:11
Recently a problem arose regarding hooking up an API with a payment processor who were requesting a string to be encrypted to be used as a token, using the TripleDES standard. Our Applications run using ColdFusion, which has an Encrypt tag - that supports TripleDES - however the result we were getting back was not what the payment processor expected. First of all, here is the resulting token the payment processor were expecting. AYOF+kRtg239Mnyc8QIarw== And below is the snippet of ColdFusion we were using, and the resulting string. <!--- Coldfusion Crypt (here be monsters) ---> <cfset theKey=

PHP Equivalent for Java Triple DES encryption/decryption

╄→尐↘猪︶ㄣ 提交于 2019-11-28 09:26:42
Am trying to decrypt a key encrypted by Java Triple DES function using PHP mcrypt function but with no luck. Find below the java code import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; public class Encrypt3DES { private byte[] key; private byte[] initializationVector; public Encrypt3DES(){ } public String encryptText(String plainText, String key) throws Exception{ //---- Use specified 3DES key and IV from other source -------------- byte[] plaintext = plainText.getBytes(); byte[] myIV = key.getBytes(); byte[] tdesKeyData = {(byte)0xA2,

TripleDES in Perl/PHP/ColdFusion

五迷三道 提交于 2019-11-27 03:19:48
问题 Recently a problem arose regarding hooking up an API with a payment processor who were requesting a string to be encrypted to be used as a token, using the TripleDES standard. Our Applications run using ColdFusion, which has an Encrypt tag - that supports TripleDES - however the result we were getting back was not what the payment processor expected. First of all, here is the resulting token the payment processor were expecting. AYOF+kRtg239Mnyc8QIarw== And below is the snippet of ColdFusion