---
title: SubtleCrypto
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/class.SubtleCrypto/
---

**Kind:** Class  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2281

## Constructor

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2282

```javascript
new SubtleCrypto()
```

## Methods

### digest

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2286

```javascript
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>
```

**Parameters**

- `algorithm`: `AlgorithmIdentifier`
- `data`: `BufferSource`

**Returns**

`Promise<ArrayBuffer>`

### importKey

_Overload 1 of 2_

```javascript
importKey(format: 'jwk', keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>
```

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2297

**Parameters**

- `format`: `'jwk'`
- `keyData`: `JsonWebKey`
- `algorithm`: `AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams`
- `extractable`: `boolean`
- `keyUsages`: `ReadonlyArray<KeyUsage>`

**Returns**

`Promise<CryptoKey>`

_Overload 2 of 2_

```javascript
importKey(format: Exclude<KeyFormat, 'jwk'>, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | HmacImportParams, extractable: boolean, keyUsages: Array<KeyUsage>): Promise<CryptoKey>
```

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2304

**Parameters**

- `format`: `Exclude<KeyFormat, 'jwk'>`
- `keyData`: `BufferSource`
- `algorithm`: `AlgorithmIdentifier | RsaHashedImportParams | HmacImportParams`
- `extractable`: `boolean`
- `keyUsages`: `Array<KeyUsage>`

**Returns**

`Promise<CryptoKey>`

### sign

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2317

```javascript
sign(algorithm: AlgorithmIdentifier, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>
```

**Parameters**

- `algorithm`: `AlgorithmIdentifier`
- `key`: `CryptoKey`
- `data`: `BufferSource`

**Returns**

`Promise<ArrayBuffer>`

### verify

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2324

```javascript
verify(algorithm: AlgorithmIdentifier, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>
```

**Parameters**

- `algorithm`: `AlgorithmIdentifier`
- `key`: `CryptoKey`
- `signature`: `BufferSource`
- `data`: `BufferSource`

**Returns**

`Promise<boolean>`
