<script src="https://webpki.lacunasoftware.com/Scripts/LacunaWebPKI/lacuna-web-pki-1.3.1.js"></script>
<div ng-app>
<div ng-controller="ExampleController">
<form>
<button type="button" ng-click="start()">Start</button>
<div id="signatureControlsPanel" ng-show="showSignatureControls">
<select ng-model="selectedCertificate" ng-options="getCertificateDisplayName(cert) for cert in certificates">
<option value="">Choose a certificate ...</option>
</select>
<button type="button" ng-click="signDummyHash()">Sign Dummy Hash</button>
</div>
</form>
<p ng-repeat="log in logs">{{log}}</p>
</div>
</div>
CSS
#signatureControlsPanel {
margin-top: 1em;
}
JavaScript
// ### DEPRECATED ###
// ------------------------------------------------------------------------------------------
// LacunaWebPKI.signHash example w/ AngularJS
function ExampleController($scope) {
$scope.signDummyHash = function () {
var selectedCertThumbprint = $scope.selectedCertificate.thumbprint;
// Base64 encoding of the SHA-256 digest of the ASCII encoding of the string "Hello, World!"
var hashToSign = '3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8=';
log('Signing hash ' + hashToSign + ' with certificate ' + selectedCertThumbprint + ' ...');
pki.signHash({
thumbprint: selectedCertThumbprint,
hash: hashToSign,
digestAlgorithm: 'SHA-256' // other equivalent inputs would be: 'SHA256', 'sha256', 'sha-256' and '2.16.840.1.101.3.4.2.1'
}).success(function (signature) {
log('Signature: ' + signature);
});
};
// ------------------------------------------------------------------------------------------
// The code from this point on is necessary for the example to run, but is not the focus of
// this specific example
$scope.logs = [];
$scope.certificates = [];
$scope.showSignatureControls = false;
var log = function (msg) {
$scope.logs.push(msg);
};
var onWebPkiError = function (message, error, origin) {
log('pki error from ' + origin + ': ' + error);
};
var myLicense = {
"format": 1,
"allowedDomains": [
"jsfiddle.net",
"webpki.lacunasoftware.com"
],
"expiration": null,
"signature":...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.