serpro / Android-PHP-Encrypt-Decrypt

Encrypt / Decrypt Between Android and PHP and vice-versa
155 stars 74 forks source link

Alternative For Swift #15

Open Kofil opened 8 years ago

Kofil commented 8 years ago

Is their any alternative solution for Swift?

kishanbarmawala commented 4 years ago

Is their any alternative solution for Swift?

Use this pod: - https://github.com/krzyzanowskim/CryptoSwift/tree/swift32

extension String { func aes_Encrypt() -> String { let key = "0123456789abcdef" let iv = "fedcba9876543210" var result = "" do { let aes = try! AES(key: key, iv: iv, padding: Padding.zeroPadding) let encrypted = try aes.encrypt(Array(self.utf8)) result = encrypted.toHexString() } catch { print(error) } return result } }

// Use:-

let str = // YOUR STRING

let result = str.aes_Encrypt() // "result" is your encrypted string