deno.land / std@0.157.0 / node / _crypto / crypto_browserify / browserify_aes / modes / ofb.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.// Copyright 2014-2017 browserify-aes contributors. All rights reserved. MIT license.// Copyright 2013 Maxwell Krohn. All rights reserved. MIT license.// Copyright 2009-2013 Jeff Mott. All rights reserved. MIT license.
import { xor } from "../xor.ts";import { Buffer } from "../../../../buffer.ts";
function getBlock(self) { self._prev = self._cipher.encryptBlock(self._prev); return self._prev;}
export const encrypt = function (self, chunk) { while (self._cache.length < chunk.length) { self._cache = Buffer.concat([self._cache, getBlock(self)]); }
const pad = self._cache.slice(0, chunk.length); self._cache = self._cache.slice(chunk.length); return xor(chunk, pad);};
std

Version Info

Tagged at
2 years ago