Comments (2)
Hi Marcin,
I just updated my test with the latest version of CryptoSwift and I'm now getting 5255ms on my machine. Far better than the 24366ms from the Swift 3 version.
Here's the code I use for the benchmark:
import Foundation
import CryptoSwift
extension Date {
func timestamp() -> Int64 {
return Int64(self.timeIntervalSince1970 * 1000)
}
}
let length = 10000000 // 10MB
let bytes = [UInt32](repeating: 0, count: length).map { _ in random() }
let data = Array(Data(bytes: bytes, count: length))
let start = Date().timestamp()
do {
let aes = try AES(key: "passwordpasswordpasswordpassword", iv: "drowssapdrowssap") // aes256
_ = try aes.encrypt(data)
print(Date().timestamp()-start)
} catch { }
You can try the snippet above on swiftplayground.run, it takes around 1600ms to complete.
I must be doing something wrong because it's still far from 753ms.
I updated the doc to reflect the new number but I'm still curious about why I'm getting such a big difference in speed.
You say that maybe I'm testing with the debug build. Can you show me a way to check which build of CryptoSwift I use in my Xcode project?
Thanks for letting me know.
from webcrypto.swift.
The values don't look right for me. The online playground runs on the slowest possible Linux virtual machine (currently) that definitely shouldn't be 4 times faster than i7 MacBook. The playground isn't also set up for the performance.
Let's use the same setup:
$ git clone https://github.com/krzyzanowskim/CryptoSwift.git
$ git checkout tests/performance
Open the CryptoSwift.xcodeproj
with Xcode 9.2, and run the testAESEncryptPerformance
test on the mac:
Unfortunately, the SPM doesn't allow to adjust all the settings, but it can be run like this:
$ swift test -c release --filter "CryptoSwiftTests.AESTests/testAESEncryptPerformance" -Xswiftc -enable-testing -Xswiftc -Ounchecked -Xswiftc -whole-module-optimization -Xswiftc -no-link-objc-runtime -Xswiftc -enforce-exclusivity=none -Xswiftc -gnone
from webcrypto.swift.
Related Issues (14)
- Can't decrypt the aes 128 encrypted string HOT 2
- CryptoJS result VS WebCrypto
- How to use decrypt function inside cellForRowAtIndexPath of tableView, as its an escaping closure
- Use of JavascriptCore framework to evaluate javascript then Webkit HOT 1
- RunLoop.current.run EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
- Not working in iOS 15
- Unable to load WebCrypto.js on iOS 9.3-9.3.3 HOT 3
- Hashing inconsistency in the web version
- Uncaught ReferenceError: md5blk is not defined
- Get crypted String HOT 1
- Cannot decrypt from AES encrypted code HOT 3
- Want to decrypt with password for 128 bit encryption? HOT 2
- Convery crypto.js algorithm to Swift HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webcrypto.swift.