[iOS] 간단한 키체인과 해싱으로 보안 강화 (Basic iOS Security: Keychain and Hashing)

이미지
[iOS] 간단한 키체인과 해싱으로 보안 강화 (Basic iOS Security: Keychain and Hashing) 민감한 데이터를 저장하고, 저장된 데이터를 안전하게 꺼내어 사용자 인증 하는 과정을 Keychain을 이용하여 구현하는 방법을 소개합니다. 해당 포스트의 원문은 다음과 같습니다 : https://www.raywenderlich.com/129-basic-ios-security-keychain-and-hashing 소스코드 다운로드 AuthViewController.signInButtonPressed() 로그인 버튼이 눌렸을 떄 호출 AuthViewController.signIn() 함수 호출 AuthViewController.signIn() 사용자의 입력 종료 이메일, 비밀번호 입력 받은 데이터 검증 디바이스의 이름 가져오기 이름, 이메일, 비밀번호로 User 데이터 만들기 AuthController.signIn() 로그인 함수 호출 AuthController.signIn() class func passwordHash(from email: String, password: String) -> String { let salt = "x4vV8bGgqqmQwgCoyXFQj+(o.nUNQhVP7ND" return "\(password).\(email).\(salt)".sha256() } 입력받은 이메일과 비밀번호를 넘겨줘 AuthController.passwordHash()로 해싱 키체인(Keychain)에서 앱의 데이터를 식별하는데 사용되는 서비스 이름을 상단에 정의 KeychainPasswordItem.savePassword()로 암호 키체인에 저장 UserDefaults에 현재 유저정보 저장 KeychainPasswordItem(service: serviceName, account: user.email).s

[swift] 구조체(struct)와 클래스(class)의 비교

이미지
[swift] 구조체(struct)와 클래스(class) 구조체와 클래스는 코드블럭을 만들 때 쓰이고 그 문법 또한 매우 닮았다. 하지만 다른점이 있기 때문에 그 특성을 잘 파악하고, 필요한 부분에서 활용할 수 있도록 정리한다. 정의 방법 (Definition) 구조체는 struct , 클래스는 class 라는 키워드를 사용하여 정의한다. struct Student{ // properties and methods } class Student { // properties and methods } 프로퍼티와 메소드 (Properties and Methods) 이 예제에서는 학생의 구조체와 클래스의 정의 예제이다. SomeStudent struct 와 AnotherStudent class 모두 firstName, lastName, grade라는 properties를 가지고 grade를 출력해주는 printGrade() 메소드를 가진다. 다른 점은 클래스에서는 init() 함수를 따로 정의 해줘야 한다. struct SomeStudent{ // properties let firstName: String let lastName: String var grade: Int // methods func printGrade(){ print("grade is \(grade)") } } class AnotherStudent { // properties let firstName: String let lastName: String var grade: Int // methods init(firstName: String, lastName: String, grade: Int){ self.firstName = firstName self.lastName = lastName self.grade = grade } func printGrade

[swift] 함수(fuction)의 기본 개념정리

이미지
[swift] 함수(fuction) 정리 같은 코드를 복사 붙여넣기 하면서 쓰지 않기 위해 함수를 사용한다. 함수의 기능에 대해 정리하면서 남긴 기록. 정의하는 방법 사용법은 간단하다 func 키워드 뒤에 함수 이름과 ()를 붙여주면된다. func printHello(){ print("hello") } 사용하는 방법 간단하다 함수이름과 빈()를 붙여주면 된다. printHello() // hello 출력 인자 넘겨주기 ()사이에 이름과 타입을 명시해주면 된다. let speedLimit = 100 let mySpeed = 80 func printSpeedViolationStatus(speed: Int){ print(speed > speedLimit ? 'Speed violation!' : 'Keep driving.') } printSpeedViolationStatus(speed: mySpeed) // Keep driving. 여러개의 인자를 넘겨주는 방법은 , 로 추가해서 넘겨준다 let speedLimit = 80 let mySpeed = 100 func printSpeedViolationStatus(speed: Int, speedLimit: Int){ print(speed > speedLimit ? 'Speed violation!' : 'Keep driving.') } printSpeedViolationStatus(speed: mySpeed, speedLimit: speedLimit) // Speed violation! 인자 기본 값(Default Parameter Values) 기본값을 넣을 수 있다. speedLimit: Int = lowLimit 와 같이 작성한다. let mySpeed = 100 let lowLimit = 80 func printSpeedViolationStatus

[WEB] 프론트엔드 개발자가 보면 좋은 페이지들

이미지
[WEB] 프론트엔드 개발가자 보면 좋은 페이지들 프론트엔드 기초 공부를 마친 개발자가 보면 좋을 페이지들을 소개한다. css-tricks 링크 : https://css-tricks.com/ css의 트릭과 html과 관련된 아티클 snippet 제공 codrops 링크 : http://tympanus.net/codrops/ html, css, js 관련 아티클, 튜토리얼 tutorialzine 링크 : https://tutorialzine.com/tag/html html, css, js 관련 아티클과 라이브러리에 대한 정보 제공 csslayout 링크 : https://csslayout.io/ css를 이용해 만든 레이아웃과 패턴들을 공유해주는 페이지 scotch 링크 : https://scotch.io/ React, Vue, Javascript, angular등의 튜토리얼 제공 codecombat 링크 : https://codecombat.com/ Javascript 문법을 이용해 게임을 할 수 있는 곳 flexboxfroggy 링크 : https://flexboxfroggy.com/#ko css 문법을 이용해 게임을 할 수 있는 곳

[IOS] Sign In With Apple 살펴보기

이미지
Sign In With Apple 살펴보기 Sign in with Apple 애플 아이디로 로그인을 할 수 있는 Sign in with Apple이 공개 된 후 적용하고 이해한 내용을 기록으로 남겨둔다. 참고 URL : https://developer.apple.com/documentation/authenticationservices/adding_the_sign_in_with_apple_flow_to_your_app 순서 : https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple#see-also 버튼 추가 새 프로젝트를 만들고 ViewController에 버튼을 호출하기 위한 함수를 추가한다. import AuthenticationServices 해준다. @IBOutlet weak var loginProviderStackView: UIStackView! 프로퍼티를 추가한다. func setupProviderLoginView() { let authorizationButton = ASAuthorizationAppleIDButton() authorizationButton.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside) self.loginProviderStackView.addArrangedSubview(authorizationButton) } @objc func handleAuthorizationAppleIDButtonPress() { } 인증 버튼 동작 extension ViewController: ASAuthorizationControllerDelegate { } exte

[swift] 오버로딩(overloading)과 오버라이딩(overriding)

이미지
오버로딩(overloading)과 오버라이딩(overriding) 오버로딩과 오버라이딩 오버로딩과 오버라이딩에 대해 정리해 놓는다. 오버로딩(overloading) 오버로딩이란 같은 이름의 메소드에 매개변수는 다르게 선언 할 수 있는 것을 의미한다. class Student { var name: String var age: Int? init(name: String, age: Int?) { self.name = name self.age = age } func printInfo(){ print("my name is \(name)") } func printInfo(age: Int){ print("my name is \(name) my age is \(age)") } } var hyunho = Student(name: "hyunho", age: nil) var jihye = Student(name: "jihye", age: 1) hyunho.printInfo() jihye.printInfo(age: jihye.age!) // my name is hyunho // my name is jihye my age is 17 위의 코드에서 이름은 필수지만 나이는 옵션이다. 이 때 자기소개 출력 함수의 경우 이름만 있을 경우와 이름과 나이가 있는경우에 다른 결과가 출력 되어야 하기 때문에 오버로딩을 통해 다른 결과를 출력했다. 오버라이딩(overriding) 상위 클래스에서 선언한 메서드를 하위 클래스에서 재정의해서 사용하는 것. class Student { var name: String var age: Int? init(name: String, age: Int?) { self.n

[swiftUI] List tutorial

이미지
[swiftUI] List tutorial 리스트(List) 리스트는 목록을 구현할 때 사용된다. 여러 데이터를 위에서 아래로 나열 할 때 사용한다. 정적 리스트(Static List) List 안에 Text(“내용”)을 반복적으로 넣어주면 리스트로 나열된다. 단쉰히 기존에 사용자가 입력 해 놓은 값들을 나열 해 줄 뿐이다. 정적 리스트는 리스트 안의 뷰를 구별할 수 있는 식별값이 없다. 그렇기 때무에 첫 번째 Leeo와 네 번째 Leeo가 같은 사람인지에 대한 삭별값이 존재하지 않는다. import SwiftUI struct ContentView : View { var body: some View { List{ HStack{ Text("My name is Leeo") Text("Age is 29") } HStack{ Text("My name is Lisa") Text("Age is 17") } HStack{ Text("My name is Sven") Text("Age is 27") } HStack{ Text("My name is Leeo") Text("Age is 29") } } } } 동적 리스트(Dynamic List) 동적 리스트는 앱이 실행되는 동안에 리스트 안의 뷰가 추가되고 삭제될 수 있다. 다음