@amazon-devices/expo-crypto是一个用于加密操作的通用库,让您能够以与Node.js核心加密API等效的方式对数据进行哈希处理。
安装
-
在
package.json文件中添加JavaScript库依赖项。 -
使用
npm install命令重新安装依赖项。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
expo-crypto 开放Beta测试文档 作为预发布开放Beta测试的一项内容,亚马逊提供了此技术文档。随着亚…
@amazon-devices/expo-crypto是一个用于加密操作的通用库,让您能够以与Node.js核心加密API等效的方式对数据进行哈希处理。
package.json文件中添加JavaScript库依赖项。
dependencies: {
...
"@amazon-devices/expo-crypto": "~2.0.1",
"@amazon-devices/keplerscript-turbomodule-api": "~1.0.0",
...
}
npm install命令重新安装依赖项。
import React, {useEffect, useState} from 'react';
import {StyleSheet, View, Text} from 'react-native';
import * as Crypto from '@amazon-devices/expo-crypto';
export const App = () => {
const [digest, setDigest] = useState<string>();
useEffect(() => {
(async () => {
const digestStr = await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256,
'GitHub stars are neat 🌟',
);
setDigest(digestStr);
})();
}, []);
return (
<View style={styles.container}>
<Text style={styles.text}>Crypto Module Example {digest}</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center',
},
text: {
fontSize: 30,
color: 'black',
},
});
| 方法 | 描述 | 支持 |
|---|---|---|
digest | 从传递的数组缓冲区(或数组缓冲区视图)中获取哈希值 | ✅ 是 |
digestStringAsync | 从传递的字符串中获取哈希值 | ✅ 是 |
getRandomBytes | 获取用随机值填充的数组缓冲区 | ✅ 是 |
getRandomBytesAsync | 获取用随机值填充的数组缓冲区 | ✅ 是 |
getRandomValues | 用随机值填充数组缓冲区。 | ✅ 是 |
randomUUID | 生成一个随机UUID | ✅ 是 |
CryptoDigestAlgorithm | Expo Crypto库的枚举。 | ✅ 是 |
MD2 | CryptoDigestAlgorithm库中唯一不支持的方法。 | ❌ 否 |
| 程序包版本 | 基于 | @amazon-devices/react-native-kepler版本 |
|---|---|---|
| 2.0.x | 12.7.0 | 2.0.x |
此页面对您有帮助吗?
