UI for Zipcoin Blue

ofb.js 415B

1234567891011121314151617
  1. var xor = require('buffer-xor')
  2. function getBlock (self) {
  3. self._prev = self._cipher.encryptBlock(self._prev)
  4. return self._prev
  5. }
  6. exports.encrypt = function (self, chunk) {
  7. while (self._cache.length < chunk.length) {
  8. self._cache = Buffer.concat([self._cache, getBlock(self)])
  9. }
  10. var pad = self._cache.slice(0, chunk.length)
  11. self._cache = self._cache.slice(chunk.length)
  12. return xor(chunk, pad)
  13. }