[TIL] 23.03.28

bpark14·2023년 3월 28일
0

WEEK 3

목록 보기
2/5

Elliptic Curves

비트코인은 디지털 서명 암호기술로, 공개키 암호기술 구현 방식의 한 종류인, ECC(Elliptic Curve Cryptography : 타원곡선 암호기술) 방식에 속하는 ECDSA(Elliptic Curve Digital Signature Algorithm) 암호 알고리즘을 사용하고 있고, 비트코인 시스템의 Security 는 ECDSA 암호 알고리즘의 Security 에 의해 결정되어 지며, ECDSA 암호 알고리즘의 Security 는 사용되는 개인키(Private-Key)의 Security에 의해 결정되어 진다.이러한 타원 곡선 암호학(Elliptic Curve Cryptography)은 줄여서 ECC라고 한다.

UTXO

사용되지 않은 출력값, Unspent Transaction Output

거래(Transaction)

특정 2개 혹은 그 이상의 주체가 통신을 하는 모든 행위를 거래라고 정의한다. 암호화폐가 이동하는 것, 메세지가 전달되는 것, 정보의 변형이 일어나는 것 등 모든 것이 거래라고 여겨진다.

날씨 API 사용하기

Web Api란?

OpenWeather API

OpenWeather API

  • 사용법
https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}

Geolocation API

Geolocation API

  • 사용법
navigator.geolocation.getCurrentPosition(
	(position) => console.log(position),
	() => alert("Location access not allowed.");
);

Call API

const API_KEY = "내 API 키";
navigator.geolocation.getCurrentPosition(
  (position) => {
    const lat = position.coords.latitude;
    const lon = position.coords.longitude;
    const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${API_KEY}&units=metric`;
    console.log(url);
  },
  () => alert("Location access not allowed.")
);

날씨정보 가져오는 전체 코드

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div>
      <div>
        <img
          class="weatherIcon"
          src="https://openweathermap.org/img/wn/10d@2x.png"
          alt="weather"
        />
      </div>
      <div class="weatherTemp">Seoul, 22℃</div>
    </div>
    <script src="main.js"></script>
  </body>
</html>

main.js

const API_KEY = "내 API 키";
const weatherIcon = document.querySelector(".weatherIcon");
const weatherTemp = document.querySelector(".weatherTemp");
navigator.geolocation.getCurrentPosition(
  (position) => {
    const lat = position.coords.latitude;
    const lon = position.coords.longitude;
    // const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${API_KEY}`;
    const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&units=metric&appid=${API_KEY}`;
    fetch(url)
      .then((response) => response.json())
      .then((data) => {
        weatherTemp.innerText =
          data.name + ", " + parseInt(data.main.temp) + "℃";
        // weatherIcon.src = `https://openweathermap.org/img/wn/${data.weather[0].icon}@2x.png`;
        weatherIcon.src =
          "https://openweathermap.org/img/wn/" +
          data.weather[0].icon +
          "@2x.png";
      });
  },
  () => alert("Not Allowed")
);

React 설치

Create React App

  • npx create-react-app my-app
profile
개발자로 성장중

0개의 댓글