digitalleaves / asymmetriccrypto Goto Github PK
View Code? Open in Web Editor NEWAsymmetric cryptography in Swift
License: MIT License
Asymmetric cryptography in Swift
License: MIT License
Hello,
I just upgraded to Swift 3 and also upgraded AssymetricCrypto. However, I am using getPublicKeyData which is now fileprivate so my code will not build. I can easily fix this by simply removing fileprivate, but I wanted to know if there is another way to get the public key data that I should be using. What I am currently doing:
AsymmetricCryptoManager.sharedInstance.createSecureKeyPair({ (success, error) in
if success {
let cryptoImportExportManager = CryptoExportImportManager()
let publicKeyData = AsymmetricCryptoManager.sharedInstance.getPublicKeyData()
publicKeyPem = cryptoImportExportManager.exportRSAPublicKeyToPEM(publicKeyData!, keyType: kSecAttrKeyTypeRSA as String, keySize: 2048)
} else {
Log.error?.message("Error creating key pair: \(error.debugDescription)")
}
Perhaps you can remove fileprivate, unless there is a better way to do the above?
Thanks.
Hey Ignacio, I just stumbled upon your repo and find this to be a good wrapper for the Security framework. I noticed in your blog post that the license adopted for this code is the MIT license. Do you mind adding this to the repo for clarity? Cheers.
I wish to use my public key to decrypt a string but I can't find any way to do so.
The asymetric crypto uses a generator for the keys.
Is there any way to make it work with my keys?
Currently, i'm trying to implement this library to generate public key in my iOS device, and save it in my database through API.
When i send this public key from this library, i modify publicKeyData using https://github.com/DigitalLeaves/CryptoExportImportManager
But, when i encrypt from my backend (GoLang), and i tried to decode the encrypted message from my backend with this code:
let encryptedData = Data(base64Encoded: encryptedMessage, options: [])
AsymmetricCryptoManager.sharedInstance.decryptMessageWithPrivateKey(encryptedData!) { (success, result, error) -> Void in
if success {
print("result: \(result)")
} else {
print("Error decoding base64 string: \(error)")
}
}
it got error decoding base64 string: Optional(com.myProjects.AsymmetricCryptoException.unableToDecrypt)
After several research, i found, Golang encrypt using EncryptPKCS1v15 (https://github.com/golang/go/blob/master/src/crypto/rsa/pkcs1v15.go)
which make the iOS app failed to decrypt it because it only has PKCS1.
What should i do to decrypt with PKCS1v15 padding ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.