etienne-martin / cryptojs.swift Goto Github PK
View Code? Open in Web Editor NEWCross-platform cryptographic functions in swift
License: MIT License
Cross-platform cryptographic functions in swift
License: MIT License
does this library support HmacSHA1?
hello, isn't there a CBC mode ? and a PKCS7 padding ? thanks
If you comment out CryptoJS.AES then the DES method will not work. Example: Comment out the ViewController class 16-38 in the project, then CryptoJS.TripleDES() will not work.
Please suggest, how to use it with hex encoded message and key.
Hi,
How can I use this library for decrypt nsdata file ?
Thanks,
vafa
I'm trying to set the encryption options in swift 3 and I'm able to get the code to compile with the code below
AES.encrypt(secretMessage: pw, secretKey: key, options: ["mode": CryptoJS.mode.ECB()] as? AnyObject)!
However this causes the app to crash when the code is run. Without the as? AnyObject
the code won't compile and I get the error Contextual type 'AnyObject' cannot be used with dictionary literal
.
Any suggestions?
Hi. I've converted CryptoJS.swift to Swift 3 using Xcode 8 converter and the converted file seems to be ok but I can't make it work.
When I try
// Load the TripleDES module
let TripleDES = CryptoJS.TripleDES()
// Basic TripleDES encryption
let encrypted = TripleDES.encrypt("secretMessage", secretKey: "password123")
print("SECRETMESSAGE: " + encrypted)
// Basic TripleDES decryption
let decrypted = TripleDES.decrypt(encrypted, secretKey: "password123")
print("RESULT: " + decrypted)
I get:
Loaded tripledes.js
SECRETMESSAGE: Optional(undefined)
RESULT: Optional(undefined)
What am I missing?
Using xcode 8.2 I get compiler warnings from the evaluateScript calls, e.g.
cryptoJScontext?evaluateScript(cryptoJS)
the warning is: Expression of type JSValue? is unused
the fix seems to be to change the lines to
let _ = cryptoJScontext?evaluateScript(cryptoJS)
Any comments?
Thanks
I have function used in cross platform application and i want to convert it into native please help me?
function fn_decryptData(var_data,var_key){
var encrypted = CryptoJS.enc.Base64.parse(var_data);
var encodedString = btoa(var_key);
var key = CryptoJS.enc.Base64.parse(encodedString);
var iv = `CryptoJS.enc.Base64.parse('somestring');`
return (CryptoJS.enc.Utf8.stringify(CryptoJS.AES.decrypt({ ciphertext: encrypted },key,{ mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7, iv: iv, })));
}
How to use this in native to decrypt data
Hi, I would like to know how to use the below js method to work in Swift:
let key = "Q8pTgdOC7h25qKVncJlzDA=="
let message = "TestAnitaa009"
let base64Key = CryptoJS.enc.Base64.parse(key);
var iv = base64Key
let encryptedValue = CryptoJS.AES.encrypt(message, base64Key, {
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
iv: base64Key
});
//The above code outputs = Oz9b31UvNTW8rFfGUOfB5A==
I tried using this library to help to do the same in Swift. But I am not able to. Any help is appreciated. Thanks a lot
Hi first of all I want to thank you for your library. I'm complete noob to data encryption and just need help with it.
Back-end API uses CryptoJS for encrypting their responses. I've tried your library and looks like it works perfect locally. It was easy. But when I try to decrypt server response it returns result "undefined"
Here is the sample of response:
"{\"ct\":\"clK4DaN8jn6uep8Uj42usi/ZfoyWBVjIK8Kx8kds5uf9cwp7l0dUheIrdcJwtgUSw70TKD/zrTYAoiRQQ6f1VxoYFroLzeKn+VWlkmqam69tHA66BOc6POnLChBxa9dOhm3Vju+y5IPTPwcclJvgFHKBsnUCdka0yfg6QvELAHef6J6hIYXnithqcSXgJZYMqlSPI0Y5qhysSj8CT9/EINC/LsHCaVEEi1q7x0BoYZ2VaZHXDKmI7Rpdksca5/BB6VoRP3Bno9r095ymoeljGBgpaY61cJLDCbTC2H500ChuwXz3HtacdtFczEu/ornk9QoRkBGc7G/zV2CMMZuiprz9OIiIrpUDVnkDOp5FljGhGCsXXB5r0tH0g1ajs7b5EUwtXV9xIMbmQTzGogJtTALrfHmp0WofTw16HNygFq/OyGbxTZBHVQlFlEdHtCubyKSSWIPJIyXhIEKaJMoSf74kF0Fmum+6cPtH/1uRcbpPrc7g3sI/7L0aO6vZhOYqtzLnk6ZcgUVx8725fWigwVVZJfVSnh2TKLN61Cyszlk5RgJ7w0Bg3Rx24QRMmpq9P6wMZO9gNabl0nA/1g2Pd8SvGux3Mo5KLqAZtRsFzrTLcZ45gR04bhFEciYce70U6JV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YQD46mif4B2PTPbC00SQ8hpFHt2EZWDJ/WR3cylKKTyzy293R0MHlpKSdKXu1sB/ao6QRTyIn8enxtv1VD1M52K2PgGaUJgm3O9vuKNhTv/bTcMux0ZtrHm828nL2YkOTW7gJtQQh0OESVRgD6thsYvgja7DZC97nMl9fDeaUaOiU5KlM4FTYF09ASSzG1OvheJ+tYDHfQXg\",\"iv\":\"1312f7120c39478c3c1a8695835608aa\",\"s\":\"f63c9a8b42209432\"}"
and a key that suppose to help:
8aa1ec1e6948b481d1ee450c94ffb2edc774877325df4d05aca2e5827497ed33
Hi,
Do this library decrypt DES files?
Thanks,
Rafa
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.