提交 6d17eac3 编写于 作者: A Annie_wang

Update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 266f0426
......@@ -51,7 +51,7 @@ For details about the supported specifications, see [HMAC Algorithm Specificatio
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------------ |
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [HMAC Algorithm Specifications](../../security/cryptoFramework-overview.md#hmac-algorithm-specifications). |
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [HMAC Algorithm Specifications](../../security/cryptoFramework-overview.md#hmac-algorithm-specifications).|
**Return value**
......@@ -483,7 +483,7 @@ For details about the supported specifications, see [MD Algorithm Specifications
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------------ |
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [MD Algorithm Specifications](../../security/cryptoFramework-overview.md#md-algorithm-specifications). |
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [MD Algorithm Specifications](../../security/cryptoFramework-overview.md#md-algorithm-specifications).|
**Return value**
......@@ -1852,7 +1852,7 @@ Updates the data to encrypt or decrypt by segment. This API uses a promise to re
| Type | Description |
| ------------------------------- | ------------------------------------------------ |
| Promise\<[DataBlob](#datablob)> | Promise used to return the **DataBlob** (containing the encrypted or decrypted data). |
| Promise\<[DataBlob](#datablob)> | Promise used to return the **DataBlob** (containing the encrypted or decrypted data).|
**Error codes**
......@@ -2174,7 +2174,7 @@ update(data : DataBlob, callback : AsyncCallback\<void>) : void
Updates the data to be signed. This API uses an asynchronous callback to return the result.
> **NOTE**<br>
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures).
> For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework
......@@ -2200,7 +2200,7 @@ update(data : DataBlob) : Promise\<void>;
Updates the data to be signed. This API uses a promise to return the result.
> **NOTE**<br>
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures).
> For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework
......@@ -2267,6 +2267,8 @@ Signs the data. This API uses a promise to return the result.
| -------------- | ----------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ---------------------- |
| 17620001 | memory error. |
......@@ -2465,7 +2467,7 @@ update(data : DataBlob, callback : AsyncCallback\<void>) : void
Updates the data for signature verification. This API uses an asynchronous callback to return the result.
> **NOTE**
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures).
> For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework
......@@ -2491,7 +2493,7 @@ update(data : DataBlob) : Promise\<void>;
Updates the data for signature verification. This API uses a promise to return the result.
> **NOTE**
> For details about the sample code for calling **update()** multiple times, see [Signing Data and Verifying Signatures](../../security/cryptoFramework-guidelines.md#signing-data-and-verifying-signatures).
> For details about the sample code for calling **update()** multiple times, see [Generating and Verifying a Signature](../../security/cryptoFramework-guidelines.md#generating-and-verifying-a-signature).
**System capability**: SystemCapability.Security.CryptoFramework
......
......@@ -67,7 +67,8 @@ Sets a security label for a file in asynchronous mode. This API uses a promise t
**Example**
```js
securityLabel.setSecurityLabel(path, "s0").then(() => {
let filePath = pathDir + '/test.txt';
securityLabel.setSecurityLabel(filePath, "s0").then(() => {
console.info("setSecurityLabel successfully");
}).catch((err) => {
console.info("setSecurityLabel failed with error message: " + err.message + ", error code: " + err.code);
......@@ -93,7 +94,8 @@ Sets a security label for a file in asynchronous mode. This API uses an asynchro
**Example**
```js
securityLabel.setSecurityLabel(path, "s0", (err) => {
let filePath = pathDir + '/test.txt';
securityLabel.setSecurityLabel(filePath, "s0", (err) => {
if (err) {
console.info("setSecurityLabel failed with error message: " + err.message + ", error code: " + err.code);
} else {
......@@ -120,7 +122,8 @@ Sets a security label for a file in synchronous mode.
**Example**
```js
securityLabel.setSecurityLabelSync(path, "s0");
let filePath = pathDir + '/test.txt';
securityLabel.setSecurityLabelSync(filePath, "s0");
```
## securityLabel.getSecurityLabel
......@@ -146,7 +149,8 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi
**Example**
```js
securityLabel.getSecurityLabel(path).then((type) => {
let filePath = pathDir + '/test.txt';
securityLabel.getSecurityLabel(filePath).then((type) => {
console.log("getSecurityLabel successfully, Label: " + type);
}).catch((err) => {
console.log("getSecurityLabel failed with error message: " + err.message + ", error code: " + err.code);
......@@ -171,7 +175,8 @@ Obtains the security label of a file in asynchronous mode. This API uses a callb
**Example**
```js
securityLabel.getSecurityLabel(path, (err, type) => {
let filePath = pathDir + '/test.txt';
securityLabel.getSecurityLabel(filePath, (err, type) => {
if (err) {
console.log("getSecurityLabel failed with error message: " + err.message + ", error code: " + err.code);
} else {
......@@ -202,6 +207,7 @@ Obtains the security label of a file in synchronous mode.
**Example**
```js
let type = securityLabel.getSecurityLabelSync(path);
let filePath = pathDir + '/test.txt';
let type = securityLabel.getSecurityLabelSync(filePath);
console.log("getSecurityLabel successfully, Label: " + type);
```
# @system.bluetooth (Bluetooth)
> **NOTE**<br/>
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md).
>
......@@ -19,11 +19,10 @@ import bluetooth from '@system.bluetooth';
Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes system resources. Call [bluetooth.stopBLEScan](#bluetoothstopblescanobject) to stop the scan after a BLE device is detected and connected.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters**
**Table 1** StartBLEScanOptions
| Name| Type| Mandatory| Description|
......@@ -42,7 +41,7 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys
console.log('call bluetooth.startBLEScan success.');
},
fail(code, data) {
console.log('call bluetooth.startBLEScan failed, code: ${code}, data: ${data}.');
console.log('call bluetooth.startBLEScan failed, code:' + code + ', data:' + data);
},
complete() {
console.log('call bluetooth.startBLEScan complete.');
......@@ -55,11 +54,10 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys
Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLEScan(OBJECT)](#bluetoothstartblescanobject) in pairs.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters**
**Table 2** StopBLEScanOptions
| Name| Type| Mandatory| Description|
......@@ -76,7 +74,7 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
console.log('call bluetooth.stopBLEScan success.');
},
fail(data, code) {
console.log('call bluethooth.stopBLEScan fail, code: ${code}, data: ${data}.');
console.log('call bluethooth.stopBLEScan fail, code:' + code + ', data:' + data);
},
complete() {
console.log('call bluethooth.stopBLEScan complete.');
......@@ -89,8 +87,6 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE
Subscribes to the newly detected BLE device. If this API is called multiple times, the last call takes effect.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Parameters**
......@@ -122,10 +118,10 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
```
bluetooth.subscribeBLEFound({
success(data) {
console.log('Called bluetooth.subscribeBLEFound successsully, data: ${data}.');
console.log('call bluetooth.subscribeBLEFound success, data: ${data}.');
},
fail(data, code) {
console.log('Failed to call bluetooth.startBLEScan, data: ${data}, code: ${code}.');
console.log('call bluetooth.startBLEScan failed, code:' + code + ', data:' + data);
}
});
```
......@@ -135,8 +131,6 @@ Subscribes to the newly detected BLE device. If this API is called multiple time
Unsubscribes from the newly detected devices.
**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
**System capability**: SystemCapability.Communication.Bluetooth.Lite
**Example**
......
# @system.cipher (Cipher Algorithm)
# @system.cipher (Cipher Algorithm)
> **NOTE**
>
> The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs provided by this module are deprecated since API version 9. You are advised to use [cryptoFramework-Cipher](js-apis-cryptoFramework.md#Cipher).
## Modules to Import
......@@ -18,9 +18,10 @@ Defines the response to the cipher interface called.
**System capability**: SystemCapability.Security.Cipher
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------ |
| text | string | Yes | Response content.|
| Name| Type | Readable| Writable|Description |
| ------ | ------ | ---- | ---- | ------------ |
| text | string | Yes | No | Response content.|
## CipherRsaOptions
......@@ -74,39 +75,39 @@ Encrypts or decrypts data using RSA.
**Example**
```js
export default {
rsa() {
cipher.rsa({
// Encrypt data.
action: 'encrypt',
// Text to be encrypted.
text: 'hello',
// Base64-encoded public key used for encryption.
key:
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx414QSP3RsYWYzf9mkBMiBAXo\n' +
'6S7Lpva1fKlcuVxjoFC1iMnzD4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ\n' +
export default {
rsa() {
cipher.rsa({
// Encrypt data.
action: 'encrypt',
// Text to be encrypted.
text: 'hello',
// Base64-encoded public key used for encryption.
key:
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx414QSP3RsYWYzf9mkBMiBAXo\n' +
'6S7Lpva1fKlcuVxjoFC1iMnzD4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ\n' +
'+Enz0RzmVFh/4yk6lmqRzuEFQqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBw\n' +
'jBpApTJ3TeneOo6Z5QIDAQAB',
success: function(data) {
console.log(`Handling successful:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.rsa encryption failed ### ${code}:${data}`);
'jBpApTJ3TeneOo6Z5QIDAQAB',
success: function(data) {
console.log(`handling success:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`);
},
complete: function() {
console.log(`operation complete!`);
}
});
cipher.rsa({
// Decrypt data.
action: 'decrypt',
// Text to be decrypted, which is binary text encoded in Base64. The decrypted text is "hello".
text:
});
cipher.rsa({
// Decrypt data.
action: 'decrypt',
// Text to be decrypted, which is binary text encoded in Base64. The decrypted text is "hello".
text:
'EPeCFPib6ayKbA0M6oSywARvFZ8dFYfjQv3nY8ikZGtS9UHq2sLPvAfpeIzggSiCxqbWeCftP1XQ\n' +
'Sa+jEpzFlT1qoSTunBbrYzugPTajIJDTg6R1IRsF/J+mmakn0POVPvi4jCo9wqavB324Bx0Wipnc\n' +
'EU5WO0oBHo5l4x6dTpU=',
// Base64-encoded private key used for decryption.
key:
'EU5WO0oBHo5l4x6dTpU=',
// Base64-encoded private key used for decryption.
key:
'MIICXgIBAAKBgQCx414QSP3RsYWYzf9mkBMiBAXo6S7Lpva1fKlcuVxjoFC1iMnz\n' +
'D4mC0uiL4k5MNi43J64c7dbqi3qAJjdAtuwQ6NZJ+Enz0RzmVFh/4yk6lmqRzuEF\n' +
'QqhQqSZzaLq6sq2N2G0Sv2Xl3sLvqAfe2HNm2oBwjBpApTJ3TeneOo6Z5QIDAQAB\n' +
......@@ -118,18 +119,18 @@ export default {
'PKoljdXmJeS6rGgzGibstuHLrP3tcIho4+0CQD3ZFWzF/xq0jxKlrpWhnJuNCRfE\n' +
'oO6e9yNvVA8J/5oEDSOcmqSNIp4+RhbUx8InUxnCG6Ryv5aSFu71pYcKrPkCQQCL\n' +
'RUGcm3ZGTnslduB0knNF+V2ndwzDUQ7P74UXT+PjurTPhujFYiuxCEd6ORVnEOzG\n' +
'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' +
'M9TORIgdH8MjIbWsGnndAkEAw9yURDaorE8IYPLF2IEn09g1uzvWPs3phDb6smVx\n' +
'8GfqIdUNf+aCG5TZK/kXBF1sqcsi7jXMAf4jBlejVbSVZg==',
success: function(data) {
console.log(`Handling successful:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.rsa encryption failed ### ${code}:${data}`);
success: function(data) {
console.log(`handling success:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`);
},
complete: function() {
console.log(`operation complete!`);
}
});
}
});
}
}
```
......@@ -152,48 +153,48 @@ Encrypts or decrypts data using AES.
**Example**
```js
export default {
aes() {
cipher.aes({
// Encrypt data.
action: 'encrypt',
// Text to be encrypted.
text: 'hello',
export default {
aes() {
cipher.aes({
// Encrypt data.
action: 'encrypt',
// Text to be encrypted.
text: 'hello',
// Base64-encoded key.
key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=',
transformation: 'AES/CBC/PKCS5Padding',
ivOffset: '0',
ivLen: '16',
success: function(data) {
console.log(`Handling successful:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.rsa encryption failed ### ${code}:${data}`);
key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=',
transformation: 'AES/CBC/PKCS5Padding',
ivOffset: '0',
ivLen: '16',
success: function(data) {
console.log(`handling success:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.rsa encrypt fail ### ${code}:${data}`);
},
complete: function() {
console.log(`operation complete!`);
}
});
cipher.aes({
// Decrypt data.
action: 'decrypt',
// Text to be decrypted, which is binary text encoded in Base64.
text: '1o0kf2HXwLxHkSh5W5NhzA==',
});
cipher.aes({
// Decrypt data.
action: 'decrypt',
// Text to be decrypted, which is binary text encoded in Base64.
text: '1o0kf2HXwLxHkSh5W5NhzA==',
// Base64-encoded key.
key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=',
transformation: 'AES/CBC/PKCS5Padding',
ivOffset: '0',
ivLen: '16',
success: function(data) {
console.log(`Handling successful:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.aes encryption failed ### ${code}:${data}`);
key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=',
transformation: 'AES/CBC/PKCS5Padding',
ivOffset: '0',
ivLen: '16',
success: function(data) {
console.log(`handling success:${data.text}`);
},
fail: function(data, code) {
console.log(`### cipher.aes encrypt fail ### ${code}:${data}`);
},
complete: function() {
console.log(`operation complete!`);
}
});
});
}
}
......
......@@ -22,8 +22,8 @@ Defines the authentication result.
| ------------ | ---------- | ---- | -------------------- |
| result | number | Yes | Authentication result. |
| token | Uint8Array | No | Token that has passed the user identity authentication.|
| remainAttempts | number | No | Number of remaining authentication times allowed.|
| lockoutDuration | number | No | Time for which the authentication operation is frozen.|
| remainAttempts | number | No | Number of remaining authentication attempts.|
| lockoutDuration | number | No | Lock duration of the authentication operation, in milliseconds.|
## TipInfo<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册