This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension AnalyticsEvent: TrackingEvent { | |
var trackingName: String { | |
MirroringHelper.name(from: self) | |
} | |
var trackingAttributes: [String: String] { | |
MirroringHelper.attributes(from: self) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CryptoSwift | |
static func decrypt(_ base64String: String, passwordUtf8: String) throws -> String { | |
let salt = Array<UInt8>.init(hex: String(base64String.prefix(32))) | |
let key = try PKCS5.PBKDF2(password: passwordUtf8.bytes, salt: salt, iterations: 100, keyLength: 16, variant: .md5).calculate() | |
let iv = Array<UInt8>.init(hex: String(base64String.prefix(64).suffix(32))) | |
let aes = try AES(key: key, blockMode: CBC(iv: iv), padding: .pkcs7) | |
let stringToDecrypt = String(base64String.suffix(base64String.count - 64)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func decrypt(_ base64String: String, passwordUtf8: String) throws -> String { | |
let encrypted = Data(base64Encoded: base64String)! | |
let salt = [UInt8](encrypted[8 ..< 16]) | |
let evp = try EVP_KDF_Util.generate_evp_kdf_aes256cbc_key_iv(pass: passwordUtf8, saltData: salt) // key + iv | |
let aes = try AES(key: Array<UInt8>.init(hex: evp.0), | |
blockMode: CBC(iv: Array<UInt8>.init(hex: evp.1)), | |
padding: .pkcs7) | |
let data = [UInt8](encrypted[16 ..< encrypted.count]) | |
let decrypted = try aes.decrypt(data) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EVP_KDF_Util { | |
public class func generate_evp_kdf_aes256cbc_key_iv(pass: String, saltData: [UInt8]) throws -> (String, String) { | |
let passData = [UInt8](pass.data(using: .utf8)!) | |
let keySize: Int = 32 | |
let keyPointer = UnsafeMutablePointer<UInt8>.allocate(capacity: keySize) | |
keyPointer.initialize(repeating: 0, count: keySize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "EVP_KDF_Salted.h" | |
#include <openssl/evp.h> | |
#include <string.h> | |
int | |
gen_evp_kdf_aes256cbc(const unsigned char *password, const unsigned char *salt, unsigned char key[], unsigned char iv[]) { | |
const EVP_CIPHER *cipher; | |
const EVP_MD *dgst = NULL; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object AESHelper { | |
private const val KEY_SIZE = 256 | |
private const val IV_SIZE = 128 | |
private const val HASH_CIPHER = "AES/CBC/PKCS7Padding" | |
private const val AES = "AES" | |
private const val KDF_DIGEST = "MD5" | |
@Throws(GeneralSecurityException::class) | |
fun decryptCryptoJS(password: String, cipherText: String): String { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
killall Xcode | |
echo 'Xcode process killed' | |
xcrun -k | |
echo 'Remove the cache. Causes all values to be re-cached' | |
xcodebuild -alltargets clean | |
echo 'clean all targets' | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" | |
echo 'ModuleCache removed' | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func CVPixelBufferGetPixelFormatName(pixelBuffer: CVPixelBuffer) -> String { | |
let p = CVPixelBufferGetPixelFormatType(pixelBuffer) | |
switch p { | |
case kCVPixelFormatType_1Monochrome: return "kCVPixelFormatType_1Monochrome" | |
case kCVPixelFormatType_2Indexed: return "kCVPixelFormatType_2Indexed" | |
case kCVPixelFormatType_4Indexed: return "kCVPixelFormatType_4Indexed" | |
case kCVPixelFormatType_8Indexed: return "kCVPixelFormatType_8Indexed" | |
case kCVPixelFormatType_1IndexedGray_WhiteIsZero: return "kCVPixelFormatType_1IndexedGray_WhiteIsZero" | |
case kCVPixelFormatType_2IndexedGray_WhiteIsZero: return "kCVPixelFormatType_2IndexedGray_WhiteIsZero" | |
case kCVPixelFormatType_4IndexedGray_WhiteIsZero: return "kCVPixelFormatType_4IndexedGray_WhiteIsZero" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Security { | |
static func isJailbroken() -> Bool { | |
guard let cydiaUrlScheme = NSURL(string: "cydia://package/com.example.package") else { return false } | |
if UIApplication.shared.canOpenURL(cydiaUrlScheme as URL) { | |
return true | |
} | |
#if arch(i386) || arch(x86_64) | |
// This is a Simulator not an idevice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Complete the isBalanced function below. | |
func isBalanced(s: String) -> String { | |
let openBrackets = "{([".replacingOccurrences(of: "", with: "") | |
let closeBrackets = "})]" | |
let brackets = ["]": "[", ")": "(", "}": "{"] | |
guard s.count > 1 else { | |
return "NO" | |
} | |
guard !closeBrackets.contains(s.first!) else { return "NO" } |
NewerOlder