swift上的代码转换错误

时间:2016-08-24 17:42:22

标签: swift uiwebview swift2

我的代码中存在问题。

    webViewMakePaymnets.delegate = self
    //Getting RSA Key

    MyViewState.rsaKey = "-----BEGIN PUBLIC KEY-----\n\( MyViewState.rsaKey)\n-----END PUBLIC KEY-----\n"
    print("\( MyViewState.rsaKey)")
    //Encrypting Card Details
    var myRequestString = "amount=\(MyViewState.amount)&currency=\(MyViewState.currency)"

    var ccTool = CCTool()

    var encVal = ccTool.encryptRSA(myRequestString, key: MyViewState.rsaKey)

    encVal = (CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(nil, (encVal as! CFString), nil, ("!*'();:@&=+$,/?%#[]" as! CFString), kCFStringEncodingUTF8)) as! String)

    //Preparing for a webview call
    var urlAsString = String(format: "https://secure.ccavenue.com/transaction/initTrans")

    var encryptedStr = "merchant_id=\(MyViewState.merchantId)&order_id=\(MyViewState.orderId)&redirect_url=\(MyViewState.redirectUrl)&cancel_url=\(MyViewState.cancelUrl)&enc_val=\(encVal)&access_code=\(MyViewState.accessCode)"

    var myRequestData = NSData(bytes: encryptedStr.UTF8String(), length: encryptedStr.length())!

    var request = NSMutableURLRequest(URL: NSURL(string: urlAsString)!)
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
    request.setValue(urlAsString, forHTTPHeaderField: "Referer")
    request.HTTPMethod = "POST"
    request!.HTTPBody = myRequestData!
    webViewMakePaymnets.loadRequest(request)

我有上面的代码,我面临的问题显示在附件中。enter image description here

0 个答案:

没有答案