Java Equivalent DES encryption?

1

I would like to know how I can.

I have a code in java

byte[] key24 = [-17, 55, 99, -54, -20, -99, -79, -34, -123, -100, -118, -42, -111, -108, -62, 123, -17, 55, 99, -54, -20, -99, -79, -34];

byte[] data = [-1, -1, -1, 0, 6, 0, 34, 96];
String algorithm = "DESede";
String mode = "DESede/ECB/NoPadding";


KeySpec confKey = new DESedeKeySpec(key24);
SecretKeyFactory spcKey = SecretKeyFactory.getInstance(algorithm);
Cipher cifermode = Cipher.getInstance(mode);
SecretKey secretKey = spcKey.generateSecret(confKey); 
output = cifermode.doFinal(data);
System.err.println("cifrado: "+output);

resultado: [-101, 23, 28, -119, -62, -119, -18, 57]

Someone knows how I can do that same but in objetive C or swift 2.3

Thanks for your time.

Hello is TripleDES encryption.

    
asked by Sergio Aldo Mejía Rodríguez 20.12.2016 в 18:11
source

1 answer

0

If anyone is interested, this is the equivalent in swift 2.3 using the library: link

If they do not know how to use it, they will download version 0.8.3, they open the project, they give it to build, they look for the framework and they are ready to just drag and copy it to their project.

internal func enctpanch(){
    let key : [UInt8] = [239, 55, 99, 202, 236, 157, 177, 222, 133, 156, 138, 214, 145, 148, 194, 123, 239, 55, 99, 202, 236, 157, 177, 222];
    let data : [UInt8] = [255, 255, 255, 0, 6, 0, 34, 96];

    let ivBytes : [UInt8] = [0,0,0,0,0,0,0,0,0];

    var cryptor = Cryptor(operation: .Encrypt, algorithm: .TripleDES, options: .ECBMode, key: key, iv: ivBytes );

    let cipherdata = cryptor.update(data)?.final();

    print("SerchCipher: \(cipherdata)");


}
    
answered by 22.12.2016 / 18:51
source