using TripleDes and MD5 in swift
<p>I have an algorithm in java code for using tripleDes and MD5. there is my java code : </p>

<pre><code> private String _encrypt(String message, String secretKey) throws Exception {

        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8"));
        byte[] keyBytes = Arrays.copyOf(digestOfPassword, 16);

        SecretKey key = new SecretKeySpec(keyBytes, "DESede/ECB/PKCS7Padding");
        Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS7Padding");
        cipher.init(Cipher.ENCRYPT_MODE, key);
        byte[] plainTextBytes = message.getBytes("utf-8");


        byte[] buf = cipher.doFinal(plainTextBytes);
        byte [] base64Bytes = Base64.encodeBase64(buf);
        String base64EncryptedString = new String(base64Bytes);

        return base64EncryptedString;
    }
</code></pre>

<p>i want to using tripleDes and MD5 in swift, i'm convert this java code to swift but there is an problem in swift because in java using 16 byte and swift using 24 byte. how can solve this difference between coding in java and swift? 
there is my swift code : </p>

<pre><code>    func myEncrypt(encryptData:String) -&gt; String?{

            let myKeyData : NSData = ("Fanava@Wrapper!1395" as NSString).data(using: String.Encoding.utf8.rawValue)! as NSData
            let myRawData : NSData = encryptData.data(using: String.Encoding.utf8)! as NSData


   let mykeydatamd5 = Data(bytes: myKeyData.bytes, count: 24) // this key convert to 24 bytes but does not hash to md5 

  let mykeydatamd5 = Data(bytes: myKeyData.md5().bytes, count: 24) // this line converted key to md5(), 24byte, but it 


            let buffer_size : size_t = myRawData.length + kCCBlockSize3DES
            let buffer = UnsafeMutablePointer&lt;NSData&gt;.allocate(capacity: buffer_size)
            var num_bytes_encrypted : size_t = 0

            let operation: CCOperation = UInt32(kCCEncrypt)
            let algoritm:  CCAlgorithm = UInt32(kCCAlgorithm3DES)
            let options:   CCOptions   = UInt32(kCCOptionECBMode | kCCOptionPKCS7Padding)
            let keyLength        = size_t(kCCKeySize3DES)

            let Crypto_status: CCCryptorStatus =  CCCrypt(operation, algoritm, options, mykeydatamd5.bytes  , keyLength, nil, myRawData.bytes, myRawData.count, buffer, buffer_size, &amp;num_bytes_encrypted)

            if UInt32(Crypto_status) == UInt32(kCCSuccess){

                let myResult: NSData = NSData(bytes: buffer, length: num_bytes_encrypted)

                free(buffer)

                return myResult.base64EncodedString(options: [])
            }else{
                free(buffer)

                return nil
            }
        }
</code></pre>