初始化环境文件
This commit is contained in:
30
node_modules/@aws-crypto/sha256-browser/src/crossPlatformSha256.ts
generated
vendored
Normal file
30
node_modules/@aws-crypto/sha256-browser/src/crossPlatformSha256.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Sha256 as WebCryptoSha256 } from "./webCryptoSha256";
|
||||
import { Sha256 as JsSha256 } from "@aws-crypto/sha256-js";
|
||||
import { Checksum, SourceData } from "@aws-sdk/types";
|
||||
import { supportsWebCrypto } from "@aws-crypto/supports-web-crypto";
|
||||
import { locateWindow } from "@aws-sdk/util-locate-window";
|
||||
import { convertToBuffer } from "@aws-crypto/util";
|
||||
|
||||
export class Sha256 implements Checksum {
|
||||
private hash: Checksum;
|
||||
|
||||
constructor(secret?: SourceData) {
|
||||
if (supportsWebCrypto(locateWindow())) {
|
||||
this.hash = new WebCryptoSha256(secret);
|
||||
} else {
|
||||
this.hash = new JsSha256(secret);
|
||||
}
|
||||
}
|
||||
|
||||
update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void {
|
||||
this.hash.update(convertToBuffer(data));
|
||||
}
|
||||
|
||||
digest(): Promise<Uint8Array> {
|
||||
return this.hash.digest();
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.hash.reset();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user