npm i --save @plmservices/nativescript-sha
- 版本:2.0.2
- GitHub: https://github.com/mcgouganp/plmservices-ns-plugins
- NPM: https://npmjs.net.cn/package/%40plmservices%2Fnativescript-sha
- 下载
- 前一天:1
- 上周:4
- 上个月:28
NativeScript SHA/HMAC

此插件提供了对iOS和Android上原生SHA生成代码的访问。
支持SHA-1、SHA-224、SHA-256、SHA-384和SHA-512。
同时支持所有支持的SHA哈希的HMAC。
先决条件/要求
无。
安装
要安装,只需运行
ns plugin add @plmservices/nativescript-sha
用法
要使用此模块,您必须首先使用 require()
它
// Javascript
var Sha = require('@plmservices/nativescript-sha');
var sha = new Sha.Sha();
或者如果您正在使用TypeScript,则 import
模块
// Typescript
import { Sha } from '@plmservices/nativescript-sha');
const sha = new Sha();
在您获得模块引用后,调用哈希函数
// Typescript
import { Sha } from '@plmservices/nativescript-sha';
const sha = new Sha();
console.log(`Hash is ${sha.Sha256("this is our test data")}`);
console.log(`Hmac is ${sha.HmacSha256("secretkey", "this is our test data")}`);
API
方法
方法 | 描述 |
---|---|
public Sha1(input: string): string; | 计算提供的输入数据的SHA1 |
public Sha224(input: string): string; | 计算提供的输入数据的SHA224 |
public Sha256(input: string): string; | 计算提供的输入数据的SHA256 |
public Sha384(input: string): string; | 计算提供的输入数据的SHA384 |
public Sha512(input: string): string; | 计算提供的输入数据的SHA512 |
public HmacSha1(key: string, input: string): string; | 使用提供的输入数据与提供的密钥计算HMAC SHA1 |
public HmacSha224(key: string, input: string): string; | 使用提供的输入数据与提供的密钥计算HMAC SHA224 |
public HmacSha256(key: string, input: string): string; | 使用提供的输入数据与提供的密钥计算HMAC SHA256 |
public HmacSha384(key: string, input: string): string; | 使用提供的输入数据与提供的密钥计算HMAC SHA384 |
public HmacSha512(key: string, input: string): string; | 使用提供的输入数据与提供的密钥计算HMAC SHA512 |
待办事项
- Angular演示应用
- Vue演示应用
捐赠
如果此项目帮助您减少了开发时间,您可以考虑用一杯咖啡或一些电力来帮助我:)
许可证
Apache许可证版本2.0,2004年1月