I am decrypting an image sent from a php server. I use CryptoSwift Library to decrypt the image; Image comes in the form of NSDT, and after decryption I am making a UII from NSDTA.
But decryption takes about 1 minute and 10 seconds, which is very slow. Image data size:
println (imageData.length) Results: 32592
I believe this is not a large file? This is the code that I use to decrypt the image data:
Let AES = AES (key: keydata, iv: ivData, block mode: .cc) decrypted data = AES? .discrypt (encrypted snap, delete: true) image = UIImage (data: decrypted data!)
I have tried to run this process on different threads, but he has the same Results given when I am decrypting the image, the simulator uses 100% CPU and 21.5 MB RAM.
Any help is appreciated, thanks!
swift 2.0
Encrypting some simple sample code here and decrypting Test code Crypto method: Output: NSData with ECB mode and 128-bit AES key.
Let's keystring = "M02cnQ51Ji97vwT4" let's keydata = (keystroke as NSString). Detauting encoding (NSUTF8StringEncoding) as an annotation! Give the message- "Do not try to read this lesson. Top Secret Stuff" data = (give message as NSSTING). Database Encoding as NSDAT (NSUFF 8 string encoding)! If you go to encryptedData = testCrypt (data, keyData: keyData, operation: UInt32 (kCCEncrypt)) print ("encryptedData: \ (encryptedData)") go to decryptedData = testCrypt (encryptedData, KeyData: keyData, operation: UInt32 (kCCDecrypt)) {print ("decryptedData: \ (decryptedData)")}}
func TestCrypt (Data: NSDTa, Key Data: NSDTA, Operation: CCOperation) - & gt; NSData? {Know keyBytes = unsafePointer & lt; UInt8 & gt; (KeyData.bytes) print ("keyLength = \ (keyData.length), keyData = \ (keyData)") go to dataLength = int (data.length) dataBytes = UnsafePointer & LT; UInt8 & gt; (Data.bytes) print ("DataLang = \ (data length), data = \ (data)") cryptdata: NSMutableData! = NSMutableData (length: int (data length) + kCCBlockSizeAES128) cryptPointer = unsafebutter pointer & lt; UInt8 & gt; (CryptData.mutableBytes) cryptLength = size_t (cryptData.length) Let's give two long = size_t (kCCKeySizeAES128) algorithms: CCAlgorithm = UInt32 (kCCAlgorithmAES128) Let's option: CCOptions = UInt32 (kCCOptionECBode + kCCOptionPKCS7Padding) var numBytesEncrypted: size_t = 0 cryptStatus = If the UInt32 (cryptStatus) == UINT32 (kCCSuccess) {cryptData.length = int (numBytesEncrypted) print (CCCrypt (Operation, Algorithm, Options, Kebites, Klemtha, Zero, DataBytes, Datelenda, CryptoPointer, Crypt Long, and amp; numbytesEncrypted) "CryptLength = \ (numBytesEncrypted), cryptData = \ (cryptData)")} else {print ("Error: \ (cryptStatus")} return cryptData; }
Data: & lt; 446f6ec2 b4742074 72792,074 6f207265 61642,074 68,697,320 74,657,874 2e20546f 70,205,365 63,726,574 20,537,475 6666 & gt; KeyLenal = 16, Keydata = & lt; 4d303263 6e513531 4a693937 76775434 & gt; DataLength = 46, data = & lt; 446f6ec2 b4742074 72792074 6f207265 61642074 686 97320 74657874 2e20546f 70205365 63726574 20537475 6666 & gt; CryptLength = 48, cryptData = & lt; 5fd86c65 6544720c 9659b43f 2e77bf8d 9c2373d9 e1042a3d ce9a19f8 2900521e c3f8075a b6866ba5 2fcd5793 bbeb8e0c & gt; EncryptedData: & lt; 5fd86c65 6544720c 9659b43f 2e77bf8d 9c2373d9 e1042a3d ce9a19f8 2900521e c3f8075a b6866ba5 2fcd5793 bbeb8e0c & gt; KeyLenal = 16, Keydata = & lt; 4d303263 6e513531 4a693937 76775434 & gt; DataLength = 48, data = & lt; 5fd86c65 6544720c 965 9B 43F2e77bf8d 9c2373d9 e1042a3d ce9a19f8 2900521e c3f8075a b6866ba5 2fcd5793 bbeb8e0c & gt; CryptLength = 46, cryptData = & lt; 446f6ec2b 4742074 72792074 6f207265 61642074 686 97320 74657874 2 E 20546F 70205365 63726574 20537475 6666 & gt; Decrypted Data: & lt; 446f6ec2b 4742074 72792074 6f207265 61642074 686 97320 74657874 2 E 20546F 70205365 63726574 20537475 6666 & gt;
No comments:
Post a Comment