提交 4976ebd2 编写于 作者: A Alex Dima

Remove SHA1 logic from base

上级 adf0be09
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
export function leftPad(value: string, length: number, char: string = '0'): string {
return new Array(length - value.length + 1).join(char) + value;
}
export function toHexString(value: number, bitsize: number = 32): string {
return leftPad((value >>> 0).toString(16), bitsize / 4);
}
export function leftRotate(value: number, bits: number, totalBits: number = 32): number {
// delta + bits = totalBits
var delta = totalBits - bits;
// All ones, expect `delta` zeros aligned to the right
var mask = ~((1 << delta) - 1);
// Join (value left-shifted `bits` bits) with (masked value right-shifted `delta` bits)
return ((value << bits) | ((mask & value) >>> delta)) >>> 0;
}
export function multiply64(a: number, b: number): number[] {
/* A1 A0 => A
* B1 B0 => B
* B0 * A1 B0 * A0
* B1 * A1 B1 * A0
* C3 C2 C1 C0 => C
*/
var a0 = a & 0xffff, a1 = a >>> 16;
var b0 = b & 0xffff, b1 = b >>> 16;
var c0 = 0, c1 = 0, c2 = 0, c3 = 0;
var x = b0 * a0;
c0 += x & 0xffff;
c1 += x >>> 16;
x = b0 * a1;
c1 += x & 0xffff;
c2 += x >>> 16;
x = b1 * a0;
c1 += x & 0xffff;
c2 += x >>> 16;
c2 += c1 >>> 16;
c1 = c1 & 0xffff;
x = b1 * a1;
c2 += x & 0xffff;
c3 += x >>> 16;
c3 += c2 >>> 16;
c2 = c2 & 0xffff;
return [(c3 << 16 | c2) >>> 0, (c1 << 16 | c0) >>> 0];
}
......@@ -2,137 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/* For reference:
http://en.wikipedia.org/wiki/UTF-8
http://en.wikipedia.org/wiki/UTF-16
*/
'use strict';
import bits = require('./bits');
export var UTF8 = 'utf8';
function byteSizeInUTF8(codePoint: number): number {
codePoint = codePoint >>> 0;
if (codePoint < 0x80) {
return 1;
} else if (codePoint < 0x800) {
return 2;
} else if (codePoint < 0x10000) {
return 3;
} else if (codePoint < 0x200000) {
return 4;
} else if (codePoint < 0x4000000) {
return 5;
} else if (codePoint < 0x80000000) {
return 6;
} else {
throw new Error('Code point 0x' + bits.toHexString(codePoint) + ' not encodable in UTF8.');
}
}
function writeUTF8(codePoint: number, buffer: Uint8Array, pos: number): number {
// How many bits needed for codePoint
var byteSize = byteSizeInUTF8(codePoint);
// 0xxxxxxx
if (byteSize === 1) {
buffer[pos] = codePoint;
return 1;
}
// 110xxxxx 10xxxxxx
// 1110xxxx 10xxxxxx 10xxxxxx
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
// 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
// first byte
buffer[pos] = ((0xfc << (6 - byteSize)) | (codePoint >>> (6 * (byteSize - 1)))) & 0xff;
// successive bytes
for (var i = 1; i < byteSize; i++) {
buffer[pos + i] = (0x80 | (0x3f & (codePoint >>> (6 * (byteSize - i - 1))))) & 0xff;
}
return byteSize;
}
export function encodeToUTF8(str: string, withBom?: boolean): ArrayBuffer {
var i: number, len: number, length = 0, charCode = 0, trailCharCode = 0, codepoint = 0;
// First pass, for the size
for (i = 0, len = str.length; i < len; i++) {
charCode = str.charCodeAt(i);
// Surrogate pair
if (charCode >= 0xd800 && charCode < 0xdc00) {
trailCharCode = str.charCodeAt(++i);
if (!(trailCharCode >= 0xdc00 && trailCharCode < 0xe000)) {
throw new Error('Invalid char code');
}
// Code point can be obtained by subtracting 0xd800 and 0xdc00 from both char codes respectively
// and joining the 10 least significant bits from each, finally adding 0x10000.
codepoint = ((((charCode - 0xd800) & 0x3ff) << 10) | ((trailCharCode - 0xdc00) & 0x3ff)) + 0x10000;
} else {
codepoint = charCode;
}
length += byteSizeInUTF8(codepoint);
}
if (withBom) {
length+= 3;
}
var result = new ArrayBuffer(length);
var view = new Uint8Array(result);
var pos = 0;
if (withBom) {
view[0] = 0xEF;
view[1] = 0xBB;
view[2] = 0xBF;
pos += 3;
}
// Second pass, for the data
for (i = 0, len = str.length; i < len; i++) {
charCode = str.charCodeAt(i);
if (charCode >= 0xd800 && charCode < 0xdc00) {
trailCharCode = str.charCodeAt(++i);
codepoint = ((((charCode - 0xd800) & 0x3ff) << 10) | ((trailCharCode - 0xdc00) & 0x3ff)) + 0x10000;
} else {
codepoint = charCode;
}
pos += writeUTF8(codepoint, view, pos);
}
return result;
}
export function encodeToUTF16(str: string, bufferView: DataView, offset: number, count: number): number {
var bytesToWrite = str.length * 2;
if (bytesToWrite > count) {
throw Error('Unable to encode string to UTF16. Need ' + bytesToWrite + ' bytes, but only have ' + count + ' bytes.');
}
for (var i = 0; i < str.length; i++) {
bufferView.setUint16(offset + i * 2, str.charCodeAt(i), false);
}
return bytesToWrite;
}
export const UTF8 = 'utf8';
export var SUPPORTED_ENCODINGS:{[encoding:string]:{ labelLong:string; labelShort:string; order:number; }} = {
export const SUPPORTED_ENCODINGS:{[encoding:string]:{ labelLong:string; labelShort:string; order:number; }} = {
utf8: {
labelLong: 'UTF-8',
labelShort: 'UTF-8',
......@@ -348,4 +222,4 @@ export var SUPPORTED_ENCODINGS:{[encoding:string]:{ labelLong:string; labelShort
labelShort: 'GB 2312',
order: 43
}
};
\ No newline at end of file
};
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import platform = require('vs/base/common/platform');
import bits = require('vs/base/common/bits/bits');
import encoding = require('vs/base/common/bits/encoding');
import types = require('vs/base/common/types');
function copy(dest: Uint8Array, destIndex: number, src: Uint8Array, srcIndex: number, count: number): number {
for (var i = 0, len = Math.min(dest.byteLength - destIndex, src.byteLength - srcIndex, count); i < len; i++) {
dest[destIndex + i] = src[srcIndex + i];
}
return len;
}
function fill(dest: Uint8Array, index: number = 0, count: number = dest.byteLength, value: number = 0): void {
for (var i = 0; i < count; i++) {
dest[index + i] = value;
}
}
export class SHA1 {
// Reference: http://en.wikipedia.org/wiki/SHA-1
private static BLOCK_SIZE = 64; // 512 / 8
private length: number;
private buffer: Uint8Array;
private bufferDV: DataView;
private bufferLength: number;
private bigBlock32: DataView;
private h0 = 0x67452301;
private h1 = 0xEFCDAB89;
private h2 = 0x98BADCFE;
private h3 = 0x10325476;
private h4 = 0xC3D2E1F0;
public static digest(data: string): string;
public static digest(data: Uint8Array): string;
public static digest(data: ArrayBuffer): string;
public static digest(data: DataView): string;
public static digest(data: any): string
{
var sha = new SHA1();
sha.update(data);
return sha.digest();
}
constructor() {
this.length = 0;
this.buffer = new Uint8Array(SHA1.BLOCK_SIZE);
this.bufferDV = new DataView(this.buffer.buffer);
this.bufferLength = 0;
this.bigBlock32 = new DataView(new ArrayBuffer(320)); // 80 * 4 = 320;
}
public update(data: string): void;
public update(data: Uint8Array): void;
public update(data: ArrayBuffer): void;
public update(data: DataView): void;
public update(arg: any): void {
if (!this.buffer) {
throw new Error('Digest already computed.');
}
var data: Uint8Array;
if (types.isString(arg)) {
data = new Uint8Array(encoding.encodeToUTF8(<string> arg));
} else if (arg instanceof ArrayBuffer) {
data = new Uint8Array(arg);
} else if (arg instanceof DataView) {
data = new Uint8Array((<DataView> arg).buffer);
} else {
data = <Uint8Array> arg;
}
var bytesRead = 0, totalBytesRead = 0;
while (totalBytesRead < data.byteLength) {
bytesRead = copy(this.buffer, this.bufferLength, data, totalBytesRead, data.byteLength);
this.bufferLength += bytesRead;
totalBytesRead += bytesRead;
if (this.bufferLength === SHA1.BLOCK_SIZE) {
this.step(this.bufferDV);
this.bufferLength = 0;
}
}
this.length += totalBytesRead;
}
public digest(): string {
if (this.buffer) {
this.wrapUp();
}
return bits.toHexString(this.h0) + bits.toHexString(this.h1) + bits.toHexString(this.h2) + bits.toHexString(this.h3) + bits.toHexString(this.h4);
}
private wrapUp(): void {
this.buffer[this.bufferLength++] = 0x80;
fill(this.buffer, this.bufferLength);
if (this.bufferLength > 56) {
this.step(this.bufferDV);
fill(this.buffer);
}
var ml = bits.multiply64(8, this.length);
this.bufferDV.setUint32(56, ml[0], false);
this.bufferDV.setUint32(60, ml[1], false);
this.step(this.bufferDV);
this.buffer = null;
this.bufferDV = null;
this.bufferLength = -1;
}
private step(data: DataView): void {
for (var j = 0; j < 64 /* 16*4 */; j += 4) {
this.bigBlock32.setUint32(j, data.getUint32(j, false), false);
}
for (j = 64; j < 320 /* 80*4 */; j += 4) {
this.bigBlock32.setUint32(j, bits.leftRotate((this.bigBlock32.getUint32(j - 12, false) ^ this.bigBlock32.getUint32(j - 32, false) ^ this.bigBlock32.getUint32(j - 56, false) ^ this.bigBlock32.getUint32(j - 64, false)), 1), false);
}
var a = this.h0;
var b = this.h1;
var c = this.h2;
var d = this.h3;
var e = this.h4;
var f: number, k: number;
var temp: number;
for (j = 0; j < 80; j++) {
if (j < 20) {
f = (b & c) | ((~b) & d);
k = 0x5A827999;
} else if (j < 40) {
f = b ^ c ^ d;
k = 0x6ED9EBA1;
} else if (j < 60) {
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
} else {
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
temp = (bits.leftRotate(a, 5) + f + e + k + this.bigBlock32.getUint32(j * 4, false)) & 0xffffffff;
e = d;
d = c;
c = bits.leftRotate(b, 30);
b = a;
a = temp;
}
this.h0 = (this.h0 + a) & 0xffffffff;
this.h1 = (this.h1 + b) & 0xffffffff;
this.h2 = (this.h2 + c) & 0xffffffff;
this.h3 = (this.h3 + d) & 0xffffffff;
this.h4 = (this.h4 + e) & 0xffffffff;
}
}
export function computeSHA1Hash(value:string, hasBOM:boolean, headerFn?:(length:number)=>string):string;
export function computeSHA1Hash(value:ArrayBuffer, hasBOM:boolean, headerFn?:(length:number)=>string):string;
export function computeSHA1Hash(value:any, hasBOM:boolean, headerFn?:(length:number)=>string):string {
if (typeof(ArrayBuffer) === 'undefined') {
return null; // IE9 does not know ArrayBuffer
}
var data = types.isString(value) ? encoding.encodeToUTF8(value, hasBOM) : <ArrayBuffer>value;
var hash = new SHA1();
if (headerFn) {
hash.update(headerFn(data.byteLength));
}
if (data.byteLength) {
hash.update(data);
}
return hash.digest();
}
\ No newline at end of file
......@@ -6,7 +6,6 @@
import Platform = require('vs/base/common/platform');
import Browser = require('vs/base/browser/browser');
import Hash = require('vs/base/common/bits/hash');
import WinJS = require('vs/base/common/winjs.base');
import Lifecycle = require('vs/base/common/lifecycle');
import DOM = require('vs/base/browser/dom');
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { multiply64, leftRotate } from 'vs/base/common/bits/bits';
suite('Bits', () => {
test('multiply64', function() {
assert.deepEqual(multiply64(0, 0), [0, 0]);
assert.deepEqual(multiply64(0, 1), [0, 0]);
assert.deepEqual(multiply64(1, 0), [0, 0]);
assert.deepEqual(multiply64(1, 1), [0, 1]);
assert.deepEqual(multiply64(42, 1), [0, 42]);
assert.deepEqual(multiply64(42, 10), [0, 420]);
assert.deepEqual(multiply64(42, 100), [0, 4200]);
assert.deepEqual(multiply64(100, 42), [0, 4200]);
assert.deepEqual(multiply64(10, 42), [0, 420]);
assert.deepEqual(multiply64(1, 42), [0, 42]);
assert.deepEqual(multiply64(0xffff, 0xffff), [0, 0xfffe0001]);
assert.deepEqual(multiply64(0xffffffff, 2), [1, 0xfffffffe]);
assert.deepEqual(multiply64(0xffffffff, 0xefef), [0xefee, 0xffff1011]);
assert.deepEqual(multiply64(0xffffffff, 0xffffffff), [0xfffffffe, 0x1]);
});
test('leftRotate', function() {
assert.deepEqual(leftRotate(0, 0), 0);
assert.deepEqual(leftRotate(0, 1), 0);
assert.deepEqual(leftRotate(0, 10), 0);
assert.deepEqual(leftRotate(0, 31), 0);
assert.deepEqual(leftRotate(0, 32), 0);
assert.deepEqual(leftRotate(1, 0), 1);
assert.deepEqual(leftRotate(1, 1), 2);
assert.deepEqual(leftRotate(1, 10), 1024);
assert.deepEqual(leftRotate(1, 31), 0x80000000);
assert.deepEqual(leftRotate(1, 32), 1);
assert.deepEqual(leftRotate(0x80000000, 1), 1);
assert.deepEqual(leftRotate(0xc0000000, 1), 0x80000001);
assert.deepEqual(leftRotate(0xc0000000, 2), 3);
assert.deepEqual(leftRotate(0xc0000000, 3), 6);
});
});
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { encodeToUTF8 } from 'vs/base/common/bits/encoding';
function eq(actual: ArrayBuffer, expected: number[]): void {
var view = new Uint8Array(actual);
var actualArray: number[] = [];
for (var i = 0; i < view.byteLength; i++) {
actualArray.push(view[i]);
}
assert.deepEqual(actualArray, expected);
}
suite('Encoding', () => {
test('encodeToUTF8', function() {
eq(encodeToUTF8(''), []);
eq(encodeToUTF8('a'), [0x61]);
eq(encodeToUTF8('aa'), [0x61, 0x61]);
eq(encodeToUTF8('aaa'), [0x61, 0x61, 0x61]);
eq(encodeToUTF8('aaaa'), [0x61, 0x61, 0x61, 0x61]);
eq(encodeToUTF8('The quick brown fox jumps over the lazy dog.'), [0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6B, 0x20, 0x62, 0x72, 0x6F, 0x77, 0x6E, 0x20, 0x66, 0x6F, 0x78, 0x20, 0x6A, 0x75, 0x6D, 0x70, 0x73, 0x20, 0x6F, 0x76, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6C, 0x61, 0x7A, 0x79, 0x20, 0x64, 0x6F, 0x67, 0x2E]);
eq(encodeToUTF8('$'), [0x24]);
eq(encodeToUTF8('¢'), [0xc2, 0xa2]);
eq(encodeToUTF8(''), [0xe2, 0x82, 0xac]);
eq(encodeToUTF8('𤭢'), [0xf0, 0xa4, 0xad, 0xa2]);
eq(encodeToUTF8('$¢€𤭢'), [0x24, 0xc2, 0xa2, 0xe2, 0x82, 0xac, 0xf0, 0xa4, 0xad, 0xa2]);
eq(encodeToUTF8('𤭢€¢$'), [0xf0, 0xa4, 0xad, 0xa2, 0xe2, 0x82, 0xac, 0xc2, 0xa2, 0x24]);
eq(encodeToUTF8('z水𐀀𝄞􏿽'), [0x7A, 0xE6, 0xB0, 0xB4, 0xF0, 0x90, 0x80, 0x80, 0xF0, 0x9D, 0x84, 0x9E, 0xF4, 0x8F, 0xBF, 0xBD]);
});
});
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { SHA1 } from 'vs/base/common/bits/hash';
import strings = require('vs/base/common/strings');
suite('Hash', () => {
test('SHA1', function() {
var sha1 = new SHA1();
sha1.update(new ArrayBuffer(0));
assert.equal(sha1.digest(), 'da39a3ee5e6b4b0d3255bfef95601890afd80709');
sha1 = new SHA1();
sha1.update('');
assert.equal(sha1.digest(), 'da39a3ee5e6b4b0d3255bfef95601890afd80709');
sha1 = new SHA1();
sha1.update('');
sha1.update('');
sha1.update('');
assert.equal(sha1.digest(), 'da39a3ee5e6b4b0d3255bfef95601890afd80709');
sha1 = new SHA1();
sha1.update('a');
assert.equal(sha1.digest(), '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8');
sha1 = new SHA1();
sha1.update('A Test');
assert.equal(sha1.digest(), '8f0c0855915633e4a7de19468b3874c8901df043');
sha1 = new SHA1();
sha1.update('A ');
sha1.update('Test');
assert.equal(sha1.digest(), '8f0c0855915633e4a7de19468b3874c8901df043');
sha1 = new SHA1();
sha1.update('A');
sha1.update(' ');
sha1.update('Test');
assert.equal(sha1.digest(), '8f0c0855915633e4a7de19468b3874c8901df043');
sha1 = new SHA1();
sha1.update('');
sha1.update('A');
sha1.update('');
sha1.update(' ');
sha1.update('');
sha1.update('Test');
sha1.update('');
assert.equal(sha1.digest(), '8f0c0855915633e4a7de19468b3874c8901df043');
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog');
assert.equal(sha1.digest(), '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12');
// 54 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick');
assert.equal(sha1.digest(), 'a9318d5d7993fd4bbad1696ece576e6e105c5872');
// 55 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick ');
assert.equal(sha1.digest(), '0558010a9a9800dc97ab12953301cba5c9d78cec');
// 56 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick b');
assert.equal(sha1.digest(), '6bb6eba88f4fae6b798459a25a46ecd420a78847');
// 63 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick brown fo');
assert.equal(sha1.digest(), '9921d82a69493909e6f8eb4821b231b0509aacf9');
// 119 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps ove');
assert.equal(sha1.digest(), '3692531d76fb737715a30169709fb2471e4b08c6');
// 119 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps ove');
assert.equal(sha1.digest(), '3692531d76fb737715a30169709fb2471e4b08c6');
// 120 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over');
assert.equal(sha1.digest(), '45762fdd4a147dc70d9331b400505562211175dc');
// 447 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy do');
assert.equal(sha1.digest(), '684e42cbb799e69004d89863ab14ecaff8a799ce');
// 448 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog');
assert.equal(sha1.digest(), 'ca1cc8eb75a8ecbe4176464046c20c2c16f653ec');
// 1125 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. ');
assert.equal(sha1.digest(), '6f16d4cf3037e7a1aa135982982b6152f6f1e1a0');
// 1125 bytes
sha1 = new SHA1();
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
sha1.update('The quick brown fox jumps over the lazy dog. ');
assert.equal(sha1.digest(), '6f16d4cf3037e7a1aa135982982b6152f6f1e1a0');
sha1 = new SHA1();
sha1.update('blob 20\0');
sha1.update('var x;\r\nvar y = x;\r\n');
assert.equal(sha1.digest(), '02352c74ec4882994b413ff8dbc009c0bdb14115');
sha1 = new SHA1();
sha1.update(strings.format('blob {0}\0', 20));
sha1.update('var x;\r\nvar y = x;\r\n');
assert.equal(sha1.digest(), '02352c74ec4882994b413ff8dbc009c0bdb14115');
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册