This file contains hidden or 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 CryptoKit | |
import Foundation | |
import CommonCrypto | |
struct Crypt { | |
private static let secretKey = "s3cr3tKeY!" | |
static func deriveKey(timestamp: Int) throws -> SymmetricKey { | |
let salt = "\(timestamp)".data(using: .utf8)! |
This file contains hidden or 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 Foundation | |
let city = "Newcastle upon Tyne" | |
let addPercentEncoding = city.addingPercentEncoding(withAllowedCharacters: CharacterSet(charactersIn: " ").inverted) | |
print(addPercentEncoding) //("Newcastle%20upon%20Tyne") |
This file contains hidden or 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
let a = 1 | |
let b = 7 | |
let min = a<b ? a : b | |
let max = a>b ? a : b | |
print(min) | |
print(max) |
This file contains hidden or 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
let a = 1 | |
let b = 7 | |
let max: Int | |
if a > b { | |
max = a | |
} else { | |
max = b | |
} | |
print("Maior: \(max)") |
This file contains hidden or 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
let a = 1 | |
let b = 7 | |
let min: Int | |
if a < b { | |
min = a | |
} else { | |
min = b | |
} | |
print("Menor: \(min)") |
This file contains hidden or 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
let primeiroValorString = "20" | |
let segungoValorStrig = "2" | |
func somaGuardLet(um: String, dois: String) -> String{ | |
guard let primeiro = Double(um) else { return ""} | |
guard let segundo = Double(dois) else { return ""} | |
let soma = primeiro + segundo | |
return String(soma) | |
} |
This file contains hidden or 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
let primeiroValorString = "20" | |
let segungoValorStrig = "3" | |
let primeiro = Double(primeiroValorString) | |
let segundo = Double(segungoValorStrig) | |
var soma = primeiro! + segundo! | |
print(soma) |