secretbox-nonce.js 624 B

123456789101112131415161718192021222324252627
  1. /**
  2. * Created by bmf on 11/3/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. var SecretBox = function SecretBoxNonce(nonce, encoding) {
  10. var self = this;
  11. CryptoBaseBuffer.call(this);
  12. self.setValidEncodings(['hex', 'base64']);
  13. self.init({
  14. expectedSize: binding.crypto_secretbox_NONCEBYTES,
  15. buffer: nonce,
  16. encoding: encoding,
  17. type: 'SecretBoxNonce'
  18. });
  19. };
  20. util.inherits(SecretBox, CryptoBaseBuffer);
  21. module.exports = SecretBox;