From da95f14c1a016d050a8900ad5c69d885c95d5292 Mon Sep 17 00:00:00 2001 From: Vitalii Goma Date: Tue, 17 Jan 2017 15:25:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/cert-list.js | 21 +++++++++++++++++++++ example/create-sign.js | 24 ++++++++++++++++++++++++ example/index.html | 18 +++++++----------- 3 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 example/cert-list.js create mode 100644 example/create-sign.js diff --git a/example/cert-list.js b/example/cert-list.js new file mode 100644 index 0000000..fb40a67 --- /dev/null +++ b/example/cert-list.js @@ -0,0 +1,21 @@ +;(function () { + 'use strict'; + + var $certs = document.querySelector('#certList'); + + /** + * Пример получения списка сертификатов + * */ + window.CryptoPro.call('getCertsList').then(function (list) { + list.forEach(function (cert) { + var $certOption = document.createElement('option'); + + $certOption.innerText = cert.label; + $certOption.value = cert.thumbprint; + + $certs.appendChild($certOption); + }); + }, function (error) { + console.error(error); + }); +}()); \ No newline at end of file diff --git a/example/create-sign.js b/example/create-sign.js new file mode 100644 index 0000000..14806bf --- /dev/null +++ b/example/create-sign.js @@ -0,0 +1,24 @@ +;(function () { + 'use strict'; + + /** + * Пример создания подписи данных, сгенерированных по ГОСТ Р 34.11-94 + * https://ru.wikipedia.org/wiki/%D0%93%D0%9E%D0%A1%D0%A2_%D0%A0_34.11-94 + * */ + var $certs = document.querySelector('#certList'), + $createSignBtn = document.querySelector('#createSign'), + $signatureCnt = document.querySelector('#createdSign'), + + // Вычислинный hash по ГОСТ Р 34.11-94 для строки: "abc" + hash = 'b285056dbf18d7392d7677369524dd14747459ed8143997e163b2986f92fd42c', + + hashBase64 = window.btoa(hash); + + $createSignBtn.addEventListener('click', function () { + var thumbprint = $certs.value; + + window.CryptoPro.call('signData', thumbprint, hashBase64).then(function (signature) { + $signatureCnt.value = signature; + }); + }); +}()); \ No newline at end of file diff --git a/example/index.html b/example/index.html index 3552b91..37c3149 100755 --- a/example/index.html +++ b/example/index.html @@ -6,22 +6,18 @@ + + +
+ + - -

-
     
-
-    
+    
+    
 
 
\ No newline at end of file