expo-crypto 10.1.0 → 10.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 10.1.1 — 2021-12-08
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 10.1.0 — 2021-12-03
14
18
 
15
19
  _This version does not introduce any user-facing changes._
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '10.1.0'
6
+ version = '10.1.1'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -57,7 +57,7 @@ android {
57
57
  minSdkVersion safeExtGet("minSdkVersion", 21)
58
58
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
59
  versionCode 25
60
- versionName "10.1.0"
60
+ versionName "10.1.1"
61
61
  }
62
62
  lintOptions {
63
63
  abortOnError false
package/build/Crypto.d.ts CHANGED
@@ -1,3 +1,23 @@
1
1
  import { CryptoDigestAlgorithm, CryptoDigestOptions, Digest } from './Crypto.types';
2
2
  export * from './Crypto.types';
3
+ /**
4
+ * The `digestStringAsync()` method of `Crypto` generates a digest of the supplied `data` string with the provided digest `algorithm`.
5
+ * A digest is a short fixed-length value derived from some variable-length input. **Cryptographic digests** should exhibit _collision-resistance_,
6
+ * meaning that it's very difficult to generate multiple inputs that have equal digest values.
7
+ * You can specify the returned string format as one of `CryptoEncoding`. By default, the resolved value will be formatted as a `HEX` string.
8
+ * On web, this method can only be called from a secure origin (https) otherwise an error will be thrown.
9
+ *
10
+ * @param algorithm The cryptographic hash function to use to transform a block of data into a fixed-size output.
11
+ * @param data The value that will be used to generate a digest.
12
+ * @param options Format of the digest string. Defaults to: `CryptoDigestOptions.HEX`.
13
+ * @return Return a Promise which fulfills with a value representing the hashed input.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const digest = await Crypto.digestStringAsync(
18
+ * Crypto.CryptoDigestAlgorithm.SHA512,
19
+ * '🥓 Easy to Digest! 💙'
20
+ * );
21
+ * ```
22
+ */
3
23
  export declare function digestStringAsync(algorithm: CryptoDigestAlgorithm, data: string, options?: CryptoDigestOptions): Promise<Digest>;
package/build/Crypto.js CHANGED
@@ -23,6 +23,27 @@ function assertEncoding(encoding) {
23
23
  throw new CryptoError(`Invalid encoding provided. Expected one of: CryptoEncoding.${Object.keys(CryptoEncoding).join(', CryptoEncoding.')}`);
24
24
  }
25
25
  }
26
+ // @needsAudit
27
+ /**
28
+ * The `digestStringAsync()` method of `Crypto` generates a digest of the supplied `data` string with the provided digest `algorithm`.
29
+ * A digest is a short fixed-length value derived from some variable-length input. **Cryptographic digests** should exhibit _collision-resistance_,
30
+ * meaning that it's very difficult to generate multiple inputs that have equal digest values.
31
+ * You can specify the returned string format as one of `CryptoEncoding`. By default, the resolved value will be formatted as a `HEX` string.
32
+ * On web, this method can only be called from a secure origin (https) otherwise an error will be thrown.
33
+ *
34
+ * @param algorithm The cryptographic hash function to use to transform a block of data into a fixed-size output.
35
+ * @param data The value that will be used to generate a digest.
36
+ * @param options Format of the digest string. Defaults to: `CryptoDigestOptions.HEX`.
37
+ * @return Return a Promise which fulfills with a value representing the hashed input.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const digest = await Crypto.digestStringAsync(
42
+ * Crypto.CryptoDigestAlgorithm.SHA512,
43
+ * '🥓 Easy to Digest! 💙'
44
+ * );
45
+ * ```
46
+ */
26
47
  export async function digestStringAsync(algorithm, data, options = { encoding: CryptoEncoding.HEX }) {
27
48
  if (!ExpoCrypto.digestStringAsync) {
28
49
  throw new UnavailabilityError('expo-crypto', 'digestStringAsync');
@@ -1 +1 @@
1
- {"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../src/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,m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C,CAAC;IAC3B,UAAU,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjC,OAAO,MAAM,UAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { CryptoDigestAlgorithm, CryptoEncoding, CryptoDigestOptions, Digest } from './Crypto.types';\nimport ExpoCrypto from './ExpoCrypto';\n\nexport * from './Crypto.types';\n\nclass CryptoError extends TypeError {\n code = 'ERR_CRYPTO';\n\n constructor(message: string) {\n super(`expo-crypto: ${message}`);\n }\n}\n\nfunction assertAlgorithm(algorithm: CryptoDigestAlgorithm): void {\n if (!Object.values(CryptoDigestAlgorithm).includes(algorithm)) {\n throw new CryptoError(\n `Invalid algorithm provided. Expected one of: CryptoDigestAlgorithm.${Object.keys(\n CryptoDigestAlgorithm\n ).join(', AlgCryptoDigestAlgorithmorithm.')}`\n );\n }\n}\n\nfunction assertData(data: string): void {\n if (typeof data !== 'string') {\n throw new CryptoError(`Invalid data provided. Expected a string.`);\n }\n}\n\nfunction assertEncoding(encoding: CryptoEncoding): void {\n if (!Object.values(CryptoEncoding).includes(encoding)) {\n throw new CryptoError(\n `Invalid encoding provided. Expected one of: CryptoEncoding.${Object.keys(\n CryptoEncoding\n ).join(', CryptoEncoding.')}`\n );\n }\n}\n\nexport async function digestStringAsync(\n algorithm: CryptoDigestAlgorithm,\n data: string,\n options: CryptoDigestOptions = { encoding: CryptoEncoding.HEX }\n): Promise<Digest> {\n if (!ExpoCrypto.digestStringAsync) {\n throw new UnavailabilityError('expo-crypto', 'digestStringAsync');\n }\n\n assertAlgorithm(algorithm);\n assertData(data);\n assertEncoding(options.encoding);\n\n return await ExpoCrypto.digestStringAsync(algorithm, data, options);\n}\n"]}
1
+ {"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../src/Crypto.ts"],"names":[],"mappings":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IAAI,mBAAmB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;KACnE;IAED,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3B,UAAU,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjC,OAAO,MAAM,UAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport { CryptoDigestAlgorithm, CryptoEncoding, CryptoDigestOptions, Digest } from './Crypto.types';\nimport ExpoCrypto from './ExpoCrypto';\n\nexport * from './Crypto.types';\n\nclass CryptoError extends TypeError {\n code = 'ERR_CRYPTO';\n\n constructor(message: string) {\n super(`expo-crypto: ${message}`);\n }\n}\n\nfunction assertAlgorithm(algorithm: CryptoDigestAlgorithm): void {\n if (!Object.values(CryptoDigestAlgorithm).includes(algorithm)) {\n throw new CryptoError(\n `Invalid algorithm provided. Expected one of: CryptoDigestAlgorithm.${Object.keys(\n CryptoDigestAlgorithm\n ).join(', AlgCryptoDigestAlgorithmorithm.')}`\n );\n }\n}\n\nfunction assertData(data: string): void {\n if (typeof data !== 'string') {\n throw new CryptoError(`Invalid data provided. Expected a string.`);\n }\n}\n\nfunction assertEncoding(encoding: CryptoEncoding): void {\n if (!Object.values(CryptoEncoding).includes(encoding)) {\n throw new CryptoError(\n `Invalid encoding provided. Expected one of: CryptoEncoding.${Object.keys(\n CryptoEncoding\n ).join(', CryptoEncoding.')}`\n );\n }\n}\n\n// @needsAudit\n/**\n * The `digestStringAsync()` method of `Crypto` generates a digest of the supplied `data` string with the provided digest `algorithm`.\n * A digest is a short fixed-length value derived from some variable-length input. **Cryptographic digests** should exhibit _collision-resistance_,\n * meaning that it's very difficult to generate multiple inputs that have equal digest values.\n * You can specify the returned string format as one of `CryptoEncoding`. By default, the resolved value will be formatted as a `HEX` string.\n * On web, this method can only be called from a secure origin (https) otherwise an error will be thrown.\n *\n * @param algorithm The cryptographic hash function to use to transform a block of data into a fixed-size output.\n * @param data The value that will be used to generate a digest.\n * @param options Format of the digest string. Defaults to: `CryptoDigestOptions.HEX`.\n * @return Return a Promise which fulfills with a value representing the hashed input.\n *\n * @example\n * ```ts\n * const digest = await Crypto.digestStringAsync(\n * Crypto.CryptoDigestAlgorithm.SHA512,\n * '🥓 Easy to Digest! 💙'\n * );\n * ```\n */\nexport async function digestStringAsync(\n algorithm: CryptoDigestAlgorithm,\n data: string,\n options: CryptoDigestOptions = { encoding: CryptoEncoding.HEX }\n): Promise<Digest> {\n if (!ExpoCrypto.digestStringAsync) {\n throw new UnavailabilityError('expo-crypto', 'digestStringAsync');\n }\n\n assertAlgorithm(algorithm);\n assertData(data);\n assertEncoding(options.encoding);\n\n return await ExpoCrypto.digestStringAsync(algorithm, data, options);\n}\n"]}
@@ -1,25 +1,55 @@
1
+ /**
2
+ * [`Cryptographic hash function`](https://developer.mozilla.org/en-US/docs/Glossary/Cryptographic_hash_function)
3
+ * is an algorithm that can be used to generate a checksum value. They have a variety of applications in cryptography.
4
+ * > Cryptographic hash functions like [`SHA1`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1),
5
+ * > `MD5` are **vulnerable**! Attacks have been proven to significantly reduce their collision resistance.
6
+ * > Message-digest algorithms shouldn't be used for creating secure digests.
7
+ */
1
8
  export declare enum CryptoDigestAlgorithm {
2
9
  /**
3
- * SHA1 is vulnerable and should not be used.
4
- * https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1
10
+ * `160` bits.
5
11
  */
6
12
  SHA1 = "SHA-1",
13
+ /**
14
+ * `256` bits. Collision Resistant.
15
+ */
7
16
  SHA256 = "SHA-256",
17
+ /**
18
+ * `384` bits. Collision Resistant.
19
+ */
8
20
  SHA384 = "SHA-384",
21
+ /**
22
+ * `512` bits. Collision Resistant.
23
+ */
9
24
  SHA512 = "SHA-512",
10
25
  /**
11
- * MD* is not supported on web.
12
- * message-digest algorithms shouldn't be used for creating secure digests.
26
+ * `128` bits.
27
+ * @platform ios
13
28
  */
14
29
  MD2 = "MD2",
30
+ /**
31
+ * `128` bits.
32
+ * @platform ios
33
+ */
15
34
  MD4 = "MD4",
35
+ /**
36
+ * `128` bits.
37
+ * @platform android
38
+ * @platform ios
39
+ */
16
40
  MD5 = "MD5"
17
41
  }
18
42
  export declare enum CryptoEncoding {
19
43
  HEX = "hex",
44
+ /**
45
+ * Has trailing padding. Does not wrap lines. Does not have a trailing newline.
46
+ */
20
47
  BASE64 = "base64"
21
48
  }
22
49
  export declare type CryptoDigestOptions = {
50
+ /**
51
+ * Format the digest is returned in.
52
+ */
23
53
  encoding: CryptoEncoding;
24
54
  };
25
55
  export declare type Digest = string;
@@ -1,24 +1,53 @@
1
+ // @needsAudit
2
+ /**
3
+ * [`Cryptographic hash function`](https://developer.mozilla.org/en-US/docs/Glossary/Cryptographic_hash_function)
4
+ * is an algorithm that can be used to generate a checksum value. They have a variety of applications in cryptography.
5
+ * > Cryptographic hash functions like [`SHA1`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1),
6
+ * > `MD5` are **vulnerable**! Attacks have been proven to significantly reduce their collision resistance.
7
+ * > Message-digest algorithms shouldn't be used for creating secure digests.
8
+ */
1
9
  export var CryptoDigestAlgorithm;
2
10
  (function (CryptoDigestAlgorithm) {
3
11
  /**
4
- * SHA1 is vulnerable and should not be used.
5
- * https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1
12
+ * `160` bits.
6
13
  */
7
14
  CryptoDigestAlgorithm["SHA1"] = "SHA-1";
15
+ /**
16
+ * `256` bits. Collision Resistant.
17
+ */
8
18
  CryptoDigestAlgorithm["SHA256"] = "SHA-256";
19
+ /**
20
+ * `384` bits. Collision Resistant.
21
+ */
9
22
  CryptoDigestAlgorithm["SHA384"] = "SHA-384";
23
+ /**
24
+ * `512` bits. Collision Resistant.
25
+ */
10
26
  CryptoDigestAlgorithm["SHA512"] = "SHA-512";
11
27
  /**
12
- * MD* is not supported on web.
13
- * message-digest algorithms shouldn't be used for creating secure digests.
28
+ * `128` bits.
29
+ * @platform ios
14
30
  */
15
31
  CryptoDigestAlgorithm["MD2"] = "MD2";
32
+ /**
33
+ * `128` bits.
34
+ * @platform ios
35
+ */
16
36
  CryptoDigestAlgorithm["MD4"] = "MD4";
37
+ /**
38
+ * `128` bits.
39
+ * @platform android
40
+ * @platform ios
41
+ */
17
42
  CryptoDigestAlgorithm["MD5"] = "MD5";
18
43
  })(CryptoDigestAlgorithm || (CryptoDigestAlgorithm = {}));
44
+ // @needsAudit
19
45
  export var CryptoEncoding;
20
46
  (function (CryptoEncoding) {
21
47
  CryptoEncoding["HEX"] = "hex";
48
+ /**
49
+ * Has trailing padding. Does not wrap lines. Does not have a trailing newline.
50
+ */
22
51
  CryptoEncoding["BASE64"] = "base64";
23
52
  })(CryptoEncoding || (CryptoEncoding = {}));
24
53
  //# sourceMappingURL=Crypto.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Crypto.types.js","sourceRoot":"","sources":["../src/Crypto.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,qBAgBX;AAhBD,WAAY,qBAAqB;IAC/B;;;OAGG;IACH,uCAAc,CAAA;IACd,2CAAkB,CAAA;IAClB,2CAAkB,CAAA;IAClB,2CAAkB,CAAA;IAClB;;;OAGG;IACH,oCAAW,CAAA;IACX,oCAAW,CAAA;IACX,oCAAW,CAAA;AACb,CAAC,EAhBW,qBAAqB,KAArB,qBAAqB,QAgBhC;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB","sourcesContent":["export enum CryptoDigestAlgorithm {\n /**\n * SHA1 is vulnerable and should not be used.\n * https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1\n */\n SHA1 = 'SHA-1',\n SHA256 = 'SHA-256',\n SHA384 = 'SHA-384',\n SHA512 = 'SHA-512',\n /**\n * MD* is not supported on web.\n * message-digest algorithms shouldn't be used for creating secure digests.\n */\n MD2 = 'MD2',\n MD4 = 'MD4',\n MD5 = 'MD5',\n}\n\nexport enum CryptoEncoding {\n HEX = 'hex',\n BASE64 = 'base64',\n}\n\nexport type CryptoDigestOptions = { encoding: CryptoEncoding };\n\nexport type Digest = string;\n"]}
1
+ {"version":3,"file":"Crypto.types.js","sourceRoot":"","sources":["../src/Crypto.types.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,qBAiCX;AAjCD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,uCAAc,CAAA;IACd;;OAEG;IACH,2CAAkB,CAAA;IAClB;;OAEG;IACH,2CAAkB,CAAA;IAClB;;OAEG;IACH,2CAAkB,CAAA;IAClB;;;OAGG;IACH,oCAAW,CAAA;IACX;;;OAGG;IACH,oCAAW,CAAA;IACX;;;;OAIG;IACH,oCAAW,CAAA;AACb,CAAC,EAjCW,qBAAqB,KAArB,qBAAqB,QAiChC;AAED,cAAc;AACd,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX;;OAEG;IACH,mCAAiB,CAAA;AACnB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB","sourcesContent":["// @needsAudit\n/**\n * [`Cryptographic hash function`](https://developer.mozilla.org/en-US/docs/Glossary/Cryptographic_hash_function)\n * is an algorithm that can be used to generate a checksum value. They have a variety of applications in cryptography.\n * > Cryptographic hash functions like [`SHA1`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1),\n * > `MD5` are **vulnerable**! Attacks have been proven to significantly reduce their collision resistance.\n * > Message-digest algorithms shouldn't be used for creating secure digests.\n */\nexport enum CryptoDigestAlgorithm {\n /**\n * `160` bits.\n */\n SHA1 = 'SHA-1',\n /**\n * `256` bits. Collision Resistant.\n */\n SHA256 = 'SHA-256',\n /**\n * `384` bits. Collision Resistant.\n */\n SHA384 = 'SHA-384',\n /**\n * `512` bits. Collision Resistant.\n */\n SHA512 = 'SHA-512',\n /**\n * `128` bits.\n * @platform ios\n */\n MD2 = 'MD2',\n /**\n * `128` bits.\n * @platform ios\n */\n MD4 = 'MD4',\n /**\n * `128` bits.\n * @platform android\n * @platform ios\n */\n MD5 = 'MD5',\n}\n\n// @needsAudit\nexport enum CryptoEncoding {\n HEX = 'hex',\n /**\n * Has trailing padding. Does not wrap lines. Does not have a trailing newline.\n */\n BASE64 = 'base64',\n}\n\n// @needsAudit\nexport type CryptoDigestOptions = {\n /**\n * Format the digest is returned in.\n */\n encoding: CryptoEncoding;\n};\n\n// @docsMissing\nexport type Digest = string;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-crypto",
3
- "version": "10.1.0",
3
+ "version": "10.1.1",
4
4
  "description": "Expo universal module for crypto",
5
5
  "main": "build/Crypto.js",
6
6
  "types": "build/Crypto.d.ts",
@@ -45,5 +45,5 @@
45
45
  "peerDependencies": {
46
46
  "expo": "*"
47
47
  },
48
- "gitHead": "2e5c6983b86d5ecfca028ba64002897d8adc2cc4"
48
+ "gitHead": "cf8e7fde1b19e10dd9b74a8af0e9362ae8e14001"
49
49
  }
package/src/Crypto.ts CHANGED
@@ -39,6 +39,27 @@ function assertEncoding(encoding: CryptoEncoding): void {
39
39
  }
40
40
  }
41
41
 
42
+ // @needsAudit
43
+ /**
44
+ * The `digestStringAsync()` method of `Crypto` generates a digest of the supplied `data` string with the provided digest `algorithm`.
45
+ * A digest is a short fixed-length value derived from some variable-length input. **Cryptographic digests** should exhibit _collision-resistance_,
46
+ * meaning that it's very difficult to generate multiple inputs that have equal digest values.
47
+ * You can specify the returned string format as one of `CryptoEncoding`. By default, the resolved value will be formatted as a `HEX` string.
48
+ * On web, this method can only be called from a secure origin (https) otherwise an error will be thrown.
49
+ *
50
+ * @param algorithm The cryptographic hash function to use to transform a block of data into a fixed-size output.
51
+ * @param data The value that will be used to generate a digest.
52
+ * @param options Format of the digest string. Defaults to: `CryptoDigestOptions.HEX`.
53
+ * @return Return a Promise which fulfills with a value representing the hashed input.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const digest = await Crypto.digestStringAsync(
58
+ * Crypto.CryptoDigestAlgorithm.SHA512,
59
+ * '🥓 Easy to Digest! 💙'
60
+ * );
61
+ * ```
62
+ */
42
63
  export async function digestStringAsync(
43
64
  algorithm: CryptoDigestAlgorithm,
44
65
  data: string,
@@ -1,26 +1,62 @@
1
+ // @needsAudit
2
+ /**
3
+ * [`Cryptographic hash function`](https://developer.mozilla.org/en-US/docs/Glossary/Cryptographic_hash_function)
4
+ * is an algorithm that can be used to generate a checksum value. They have a variety of applications in cryptography.
5
+ * > Cryptographic hash functions like [`SHA1`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1),
6
+ * > `MD5` are **vulnerable**! Attacks have been proven to significantly reduce their collision resistance.
7
+ * > Message-digest algorithms shouldn't be used for creating secure digests.
8
+ */
1
9
  export enum CryptoDigestAlgorithm {
2
10
  /**
3
- * SHA1 is vulnerable and should not be used.
4
- * https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#SHA-1
11
+ * `160` bits.
5
12
  */
6
13
  SHA1 = 'SHA-1',
14
+ /**
15
+ * `256` bits. Collision Resistant.
16
+ */
7
17
  SHA256 = 'SHA-256',
18
+ /**
19
+ * `384` bits. Collision Resistant.
20
+ */
8
21
  SHA384 = 'SHA-384',
22
+ /**
23
+ * `512` bits. Collision Resistant.
24
+ */
9
25
  SHA512 = 'SHA-512',
10
26
  /**
11
- * MD* is not supported on web.
12
- * message-digest algorithms shouldn't be used for creating secure digests.
27
+ * `128` bits.
28
+ * @platform ios
13
29
  */
14
30
  MD2 = 'MD2',
31
+ /**
32
+ * `128` bits.
33
+ * @platform ios
34
+ */
15
35
  MD4 = 'MD4',
36
+ /**
37
+ * `128` bits.
38
+ * @platform android
39
+ * @platform ios
40
+ */
16
41
  MD5 = 'MD5',
17
42
  }
18
43
 
44
+ // @needsAudit
19
45
  export enum CryptoEncoding {
20
46
  HEX = 'hex',
47
+ /**
48
+ * Has trailing padding. Does not wrap lines. Does not have a trailing newline.
49
+ */
21
50
  BASE64 = 'base64',
22
51
  }
23
52
 
24
- export type CryptoDigestOptions = { encoding: CryptoEncoding };
53
+ // @needsAudit
54
+ export type CryptoDigestOptions = {
55
+ /**
56
+ * Format the digest is returned in.
57
+ */
58
+ encoding: CryptoEncoding;
59
+ };
25
60
 
61
+ // @docsMissing
26
62
  export type Digest = string;