Compare commits
No commits in common. "master" and "3.3.0" have entirely different histories.
21
LICENSE copy
21
LICENSE copy
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -2,14 +2,6 @@
|
|||
> 本模块是对原生的`crypto`模块二次封装的,在使用上更加简单方便。
|
||||
|
||||
## 更新日志
|
||||
+ v3.3.4
|
||||
- 添加MIT开源协议
|
||||
|
||||
+ v3.3.3
|
||||
- 优化`.d.ts`参数声明
|
||||
|
||||
+ v3.3.1
|
||||
- 优化`.d.ts`参数声明
|
||||
|
||||
+ v3.3.0
|
||||
- 增加 `.d.ts`, 默认为esm加载
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "crypto.js",
|
||||
"type": "module",
|
||||
"version": "3.3.4",
|
||||
"version": "3.3.0",
|
||||
"description": "原生crypto加密模块的二次封装,简化常用加密函数的使用",
|
||||
"keywords": [
|
||||
"md5",
|
||||
|
@ -19,7 +19,6 @@
|
|||
"type": "git",
|
||||
"url": "https://git.wkit.fun/bytedo/crypto.js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
|
@ -29,7 +28,6 @@
|
|||
"start": "node ./build.js"
|
||||
},
|
||||
"exports": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
|
|
|
@ -3,49 +3,42 @@
|
|||
* @author yutent<yutent.io@gmail.com>
|
||||
* @date 2024/12/12 15:41:25
|
||||
*/
|
||||
|
||||
declare module 'crypto.js' {
|
||||
import crypto from 'node:crypto'
|
||||
|
||||
// 原生 crypto 模块
|
||||
export { crypto }
|
||||
|
||||
/**
|
||||
* @deprecated Use `crypto` instead.
|
||||
*/
|
||||
export const origin: typeof crypto
|
||||
|
||||
// 随机数生成
|
||||
export function rand(len: number, forceNum?: boolean): string
|
||||
export function rand(len: number, forceNum: boolean): string
|
||||
|
||||
// 生成唯一 uuid
|
||||
export function uuid(pipe?: string): string
|
||||
export function uuid(pipe: string): string
|
||||
|
||||
export function base64encode(str: string, urlFriendly?: boolean): string
|
||||
export function base64encode(str: string, urlFriendly: boolean): string
|
||||
|
||||
export function base64decode(str: string, urlFriendly?: boolean): string
|
||||
export function base64decode(str: string, urlFriendly: boolean): string
|
||||
|
||||
export function md5(data: string, encode?: string): string | Buffer
|
||||
export function md5(data: string, encode: string): string | Buffer
|
||||
|
||||
export function md5Sign(path: string, encode?: string): string | Buffer
|
||||
export function md5Sign(path: string, encode: string): string | Buffer
|
||||
|
||||
export function sha1(data: string, encode?: string): string | Buffer
|
||||
export function sha1(data: string, encode: string): string | Buffer
|
||||
|
||||
export function sha1Sign(path: string, encode?: string): string | Buffer
|
||||
export function sha1Sign(path: string, encode: string): string | Buffer
|
||||
|
||||
export function sha256(data: string, encode?: string): string | Buffer
|
||||
export function sha256(data: string, encode: string): string | Buffer
|
||||
|
||||
export function sha256Sign(path: string, encode?: string): string | Buffer
|
||||
export function sha256Sign(path: string, encode: string): string | Buffer
|
||||
|
||||
export function sha512(data: string, encode?: string): string | Buffer
|
||||
export function sha1(data: string, encode: string): string | Buffer
|
||||
|
||||
export function sha512Sign(path: string, encode?: string): string | Buffer
|
||||
export function sha1Sign(path: string, encode: string): string | Buffer
|
||||
|
||||
export function sha512(data: string, encode: string): string | Buffer
|
||||
|
||||
export function sha512Sign(path: string, encode: string): string | Buffer
|
||||
|
||||
//
|
||||
export function hash(
|
||||
mode: string,
|
||||
data: string | Buffer,
|
||||
outEncode?: string
|
||||
outEncode: string
|
||||
): string | Buffer
|
||||
|
||||
//
|
||||
|
@ -53,7 +46,7 @@ declare module 'crypto.js' {
|
|||
mode: string,
|
||||
data: string | Buffer,
|
||||
key: string | Buffer,
|
||||
outEncode?: string
|
||||
outEncode: string
|
||||
): string | Buffer
|
||||
|
||||
//
|
||||
|
@ -61,8 +54,8 @@ declare module 'crypto.js' {
|
|||
mode: string,
|
||||
data: string | Buffer,
|
||||
key: string | Buffer,
|
||||
inEncode?: string,
|
||||
outEncode?: string
|
||||
inEncode: string,
|
||||
outEncode: string
|
||||
): string | Buffer
|
||||
|
||||
//
|
||||
|
@ -70,8 +63,8 @@ declare module 'crypto.js' {
|
|||
mode: string,
|
||||
data: string | Buffer,
|
||||
key: string | Buffer,
|
||||
inEncode?: string,
|
||||
outEncode?: string
|
||||
inEncode: string,
|
||||
outEncode: string
|
||||
): string | Buffer
|
||||
|
||||
//
|
||||
|
@ -80,8 +73,8 @@ declare module 'crypto.js' {
|
|||
data: string | Buffer,
|
||||
key: string | Buffer,
|
||||
iv: string | Buffer,
|
||||
inEncode?: string,
|
||||
outEncode?: string
|
||||
inEncode: string,
|
||||
outEncode: string
|
||||
): string | Buffer
|
||||
|
||||
//
|
||||
|
@ -90,7 +83,7 @@ declare module 'crypto.js' {
|
|||
data: string | Buffer,
|
||||
key: string | Buffer,
|
||||
iv: string | Buffer,
|
||||
inEncode?: string,
|
||||
outEncode?: string
|
||||
inEncode: string,
|
||||
outEncode: string
|
||||
): string | Buffer
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ export function base64decode(str, urlFriendly) {
|
|||
* @param {[type]} len [要得到的字符串长度]
|
||||
* @param {[type]} forceNum [是否强制返回纯数字]
|
||||
*/
|
||||
export function rand(len = 0, forceNum = false) {
|
||||
export function rand(len, forceNum) {
|
||||
let str = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789'
|
||||
if (forceNum) {
|
||||
str = '0123456789'
|
||||
|
|
Loading…
Reference in New Issue