// // MLCryptoTests.swift // MLCryptoTests // // Created by Anurodh Pokharel on 1/7/20. // Copyright © 2020 Anurodh Pokharel. All rights reserved. // import XCTest @testable import monalxmpp class MLCryptoTests: XCTestCase { override func setUp() { // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. } func testEncrypt() { let crypto = MLCrypto(); let input = "Monal" let key = dataWithHexString(hex:"b1eccf9b3afc566e763ba0968e6b5b58"); let encrypted = crypto.encryptGCM(key: key,decryptedContent: input.data(using: .utf8)!) XCTAssert(encrypted != nil) let decrypted = crypto.decryptGCM(key:key, encryptedContent:encrypted!.combined!) let result = String(data: decrypted!, encoding: .utf8) XCTAssert(result == input); } func dataWithHexString(hex: String) -> Data { var hex = hex var data = Data() while(hex.count > 0) { let subIndex = hex.index(hex.startIndex, offsetBy: 2) let c = String(hex[..