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 @@
+ + +