auth-key.js 683 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Created by bmf on 11/2/13.
  3. */
  4. /* jslint node: true */
  5. 'use strict';
  6. var util = require('util');
  7. var binding = require('../../build/Release/sodium');
  8. var CryptoBaseBuffer = require('../crypto-base-buffer');
  9. /**
  10. * Message Authentication Secret Key
  11. *
  12. * @param {String|Buffer|Array} key secret key
  13. */
  14. var Auth = function AuthKey(key, encoding) {
  15. var self = this;
  16. CryptoBaseBuffer.call(this);
  17. self.init({
  18. expectedSize: binding.crypto_auth_KEYBYTES,
  19. buffer: key,
  20. encoding: encoding,
  21. type: 'AuthKey'
  22. });
  23. self.setValidEncodings(['hex', 'base64']);
  24. };
  25. util.inherits(Auth, CryptoBaseBuffer);
  26. module.exports = Auth;