2
0

service.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. /* jshint node:true */
  9. 'use strict';
  10. var MessageDigester = require('./digester');
  11. var cryptoPolicy = require('scytl-cryptopolicy');
  12. module.exports = MessageDigestService;
  13. /**
  14. * @class MessageDigestService
  15. * @classdesc The message digest service API. To instantiate this object, use
  16. * the method {@link newService}.
  17. * @hideconstructor
  18. * @param {Object}
  19. * [options] An object containing optional arguments.
  20. * @param {Policy}
  21. * [options.policy=Default policy] The cryptographic policy to use.
  22. */
  23. function MessageDigestService(options) {
  24. options = options || {};
  25. var policy;
  26. if (options.policy) {
  27. policy = options.policy;
  28. } else {
  29. policy = cryptoPolicy.newInstance();
  30. }
  31. /**
  32. * Creates a new MessageDigester object for generating message digests.
  33. *
  34. * @function newDigester
  35. * @memberof MessageDigestService
  36. * @returns {MessageDigester} The new MessageDigester object.
  37. */
  38. this.newDigester = function() {
  39. return new MessageDigester(policy);
  40. };
  41. }