aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/window/crypto/index.html
blob: 1b43534adcf429cc277a8f484b171b2fe1a83e63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
title: Window.crypto
slug: Web/API/Window/crypto
tags:
  - API
  - HTML DOM
  - Property
  - Reference
  - Window
translation_of: Web/API/Window/crypto
---
<div>{{APIRef}}</div>

<p><span class="seoSummary"><strong><code>Window.crypto</code></strong>속성은 전역 객체인 {{domxref("Crypto")}} 객체를 반환합니다. <code>Crypto</code> 객체는 웹 페이지가 특정 암호학적 서비스에 접근할 수 있는 경로입니다.</span> <code>crypto</code> 속성 자체는 읽기 전용이지만, 모든 메서드(와 자식 객체 {{domxref("SubtleCrypto")}})의 메서드)는 읽기 전용이 아니므로 {{glossary("polyfill", "폴리필")}}을 통한 공격에 취약합니다.</p>

<h2 id="구문">구문</h2>

<pre class="syntaxbox">var <em>cryptoObj</em> = window.crypto || window.msCrypto; // for IE 11
</pre>

<h2 id="예제">예제</h2>

<p id="Using_the_domxrefWindow.crypto_property_to_access_the_getRandomValues_method.">다음 예제는 {{domxref("Window.crypto")}} 속성을 통해 {{domxref("Crypto.getRandomValues", "getRandomValues()")}} 메서드에 접근합니다.</p>

<h3 id="JavaScript">JavaScript</h3>

<pre class="brush: js">genRandomNumbers = function getRandomNumbers() {
  var array = new Uint32Array(10);
  window.crypto.getRandomValues(array);

  var randText = document.getElementById("myRandText");
  randText.innerHTML = "The random numbers are: "
  for (var i = 0; i &lt; array.length; i++) {
    randText.innerHTML += array[i] + " ";
  }
}</pre>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;p id="myRandText"&gt;The random numbers are: &lt;/p&gt;
&lt;button type="button" onClick='genRandomNumbers()'&gt;Generate 10 random numbers&lt;/button&gt;</pre>

<h3 id="결과">결과</h3>

<p>{{EmbedLiveSample('예제')}}</p>

<h2 id="명세">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">명세</th>
   <th scope="col">상태</th>
   <th scope="col">비고</th>
  </tr>
  <tr>
   <td>{{SpecName("Web Crypto API", "#dfn-GlobalCrypto", "Window.crypto")}}</td>
   <td>{{Spec2("Web Crypto API")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>



<p>{{Compat("api.Window.crypto")}}</p>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li>{{domxref("Window")}} 전역 객체</li>
 <li>{{domxref("Crypto")}} 인터페이스</li>
</ul>