3des

3DES encrypt result in PHP, JAVA and .NET produces different result from 3DES iOS

假如想象 提交于 2019-12-04 23:27:38
I'm trying to upgrade my current app in iOS 8, to adapt to the new encryption SHA256 of Redsys / Sermpa. But I have problems in data encryption. In PHP, Java and .NET I get a result, completely different from iOS. I think the problem must be in the 3DES IOS CCCrypt. The PHP, JAVA and .NET code is a library, I can not alter that library. I have to make the result of encryption in iOS, is identical to right result encrypt in PHP, JAVA and .NET. Library Java Code: String secretCodeString = "Mk9m98IfEblmPfrpsawt7BmxObt98Jev"; String Ds_Merchant_Order = "1442772645"; String Ds_MerchantParameters =

Java Triple DES encryption with 2 different keys

时光总嘲笑我的痴心妄想 提交于 2019-12-04 21:50:58
I'm trying to encrypt data using triple DES with two different keys, so given the two keys k1 and k2 the cryptotext would be Ek1(Dk2(Ek1(plaintext))) where E is Encryption and D Decryption. I'm trying to simulate this using DES algorithm from java. Here is the code: public static void main(String[] args) { SecretKey k1 = generateDESkey(); SecretKey k2 = generateDESkey(); String firstEncryption = desEncryption("plaintext", k1); String decryption = desDecryption(firstEncryption, k2); String secondEncryption = desEncryption(decryption, k1); } public static SecretKey generateDESkey() {

NoSuchProviderException when encrypting string with 3DES

让人想犯罪 __ 提交于 2019-12-04 21:07:13
I am new to Java. I followed this tutorial about Encryption and Decryption using 3DES algorithm. I have implemented like this: Created a class and placed the 3DES code provided in the above link. Called the encrypt method in the above link as below: String encryptedPassword = Encrypter.encrypt(edtText.getText().toString()); I am getting the exception in logcat as below: 05-02 15:19:10.804: W/System.err(4445): java.security.NoSuchProviderException: Provider not available: SunJCE 05-02 15:19:10.820: W/System.err(4445): at javax.crypto.Cipher.getInstance(Cipher.java:209) 05-02 15:19:10.820: W

Decrypting data in Python that was encrypted in 3DES by Java

≯℡__Kan透↙ 提交于 2019-12-04 19:09:32
I'm trying to decrypt data using PyCrypto. The data was encoded in Java with the javax.crypto package. The encryption is Triple DES (referred to as " DESede " in Java). As far as I can tell, default settings are used for everything. However, when I go to decrypt the data in Python there is always a problem with the data. Here's the Java code that does encrypting/decrypting: import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESedeKeySpec; import java.security

Triple DES encryption on C# and PHP yields different results

泄露秘密 提交于 2019-12-04 14:55:28
I'm writing a simple encryption system for logging in but I've got small issue. C# encrypt function: public static string EncryptString(string Message, string Passphrase) { byte[] Results; System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding(); // Step 1. We hash the passphrase using MD5 // We use the MD5 hash generator as the result is a 128 bit byte array // which is a valid length for the TripleDES encoder we use below MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider(); byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase)); // Step 2. Create a new

How to perform Triple DES calculations in Ruby in hexadecimal?

纵饮孤独 提交于 2019-12-03 21:46:10
I'm trying to do some triple DES encryption in Ruby. I'm trying to replicate the results from this page: http://da.nmilne.com/des.html I'm trying to replicate those result in Ruby. I suspect the problem is the key is supposed to be a string, but I need to pass in a Hexadecimal key. Either that or the string being encrypted is in the wrong format. Or maybe both. :-) require 'openssl' des = OpenSSL::Cipher::Cipher.new("des-ede-cbc") des.encrypt des.key="23232323232323234545454545454545" des.update("0000000000000000") res=des.final res.unpack('H*') => ["5045c5d37ca4d13b"] But it should be: => [

How ciphertext was generated in card reader using DUKPT encryption?

扶醉桌前 提交于 2019-12-02 19:43:50
For `BDK = "0123456789ABCDEFFEDCBA9876543210"` `KSN = "FFFF9876543210E00008"` The ciphertext generated was below "C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC1FD11D9F7E74886742D9BEE0CFD1EA1064C213BB55278B2F12"` which I found here . I know this cipher-text is based on BDK and KSN but how this 128 length cipher text was generated? What are steps involved in it or algorithm used for this? Could someone explain in simple steps. I found it hard to understand the documents I got while googled. Regarding DUKPT , there are some explanations given on Wiki . If that

In ios 3des encryption contain lots of null termination.when i convert NSData to NSString , it will endup to first null termination?

淺唱寂寞╮ 提交于 2019-12-02 13:12:08
问题 i have used this function for 3des encryption. ccStatus = CCCrypt(kCCEncrypt, // CCoperation op kCCAlgorithm3DES, // CCAlgorithm alg kCCOptionPKCS7Padding, // kCCOptionPKCS7Padding, //kCCModeECB, // CCOptions [_keyData bytes], // const void *key kCCKeySize3DES, // 3DES key size length 24 bit vinitVec, //iv, // const void *iv, [dTextIn bytes], // const void *dataIn [dTextIn length], // size_t dataInLength bufferPtr, // void *dataOut bufferPtrSize, // size_t dataOutAvailable &movedBytes); //

iOS 3DES encryption for TPV payments

試著忘記壹切 提交于 2019-12-02 07:39:31
I'm developing an iOS app that makes payments through a TPV Redsys API. I'm following the documents but it's not working (server returns error due to an incorrect signature) and I guess it's because of the 3DES encryption. I'm using the test data from the documentation so the output should be the same as in the documentation. This is my code: - (void) payViaTPVWithAmount:(NSString *)amount andOrderId:(NSString *)orderId { // I don't use my amount and orderId but those provided by the documentation to test // We need to obtain 3 fields: DS_SIGNATURE_VERSION, DS_MERCHANTPARAMETERS and DS

iOS 3DES with ECB return half correct data

孤街浪徒 提交于 2019-12-02 00:15:57
问题 Got a problem with crypting password with 3DES + ECB algo. Here is the code I using: class func encryptPassword(pass: String) -> String { let keyString = "123456789012345678901234" let keyData: NSData! = (keyString as NSString).dataUsingEncoding(NSUTF8StringEncoding) as NSData! let keyBytes = UnsafePointer<UInt8>(keyData.bytes) let data: NSData! = (pass as NSString).dataUsingEncoding(NSUTF8StringEncoding) as NSData! let dataLength = UInt(data.length) let dataBytes = UnsafePointer<UInt8>(data