New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eyhn/crypto

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eyhn/crypto - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

lib/pkcs1/decrypt.d.ts

@@ -1,1 +0,1 @@

export default function pkcs1decrypt(d: ArrayBuffer, n: ArrayBuffer, buffer: ArrayBuffer): Uint8Array;
export default function pkcs1decrypt(d: ArrayBuffer, n: ArrayBuffer, buffer: ArrayBuffer): ArrayBuffer;

@@ -1,1 +0,1 @@

export default function pkcs1unpadding(b: ArrayBuffer, n: number): Uint8Array;
export default function pkcs1unpadding(b: ArrayBuffer, n: number): ArrayBuffer;

@@ -15,5 +15,5 @@ "use strict";

++point;
return view.slice(point);
return view.slice(point).buffer;
}
exports.default = pkcs1unpadding;
//# sourceMappingURL=unpadding.js.map

@@ -1,2 +0,2 @@

export declare function textToArrayBuffer(s: string): ArrayBuffer | SharedArrayBuffer;
export declare function textToArrayBuffer(s: string): ArrayBuffer;
export declare function arrayBufferToText(buffer: ArrayBuffer): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function textToArrayBuffer(s) {
var i = s.length;
var n = 0;
var ba = new Array();
for (var j = 0; j < i;) {
var c = s.codePointAt(j);
if (c < 128) {
ba[n++] = c;
j++;
}
else if ((c > 127) && (c < 2048)) {
ba[n++] = (c >> 6) | 192;
ba[n++] = (c & 63) | 128;
j++;
}
else if ((c > 2047) && (c < 65536)) {
ba[n++] = (c >> 12) | 224;
ba[n++] = ((c >> 6) & 63) | 128;
ba[n++] = (c & 63) | 128;
j++;
}
else {
ba[n++] = (c >> 18) | 240;
ba[n++] = ((c >> 12) & 63) | 128;
ba[n++] = ((c >> 6) & 63) | 128;
ba[n++] = (c & 63) | 128;
j += 2;
}
var buf = new ArrayBuffer(s.length * 2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i = 0, strLen = s.length; i < strLen; i++) {
bufView[i] = s.charCodeAt(i);
}
return new Uint8Array(ba).buffer;
return buf;
}
exports.textToArrayBuffer = textToArrayBuffer;
function arrayBufferToText(buffer) {
return String.fromCharCode.apply(null, new Uint8Array(buffer));
return String.fromCharCode.apply(null, new Uint16Array(buffer));
}
exports.arrayBufferToText = arrayBufferToText;
//# sourceMappingURL=text.js.map
{
"name": "@eyhn/crypto",
"version": "1.1.1",
"version": "1.1.2",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "types": "lib/index.d.ts",

@@ -12,3 +12,3 @@ export default function pkcs1unpadding(b: ArrayBuffer, n: number) {

return view.slice(point);
return view.slice(point).buffer;
}
export function textToArrayBuffer(s: string) {
var i = s.length;
var n = 0;
var ba = new Array()
for (var j = 0; j < i;) {
var c = s.codePointAt(j);
if (c < 128) {
ba[n++] = c;
j++;
}
else if ((c > 127) && (c < 2048)) {
ba[n++] = (c >> 6) | 192;
ba[n++] = (c & 63) | 128;
j++;
}
else if ((c > 2047) && (c < 65536)) {
ba[n++] = (c >> 12) | 224;
ba[n++] = ((c >> 6) & 63) | 128;
ba[n++] = (c & 63) | 128;
j++;
}
else {
ba[n++] = (c >> 18) | 240;
ba[n++] = ((c >> 12) & 63) | 128;
ba[n++] = ((c >> 6) & 63) | 128;
ba[n++] = (c & 63) | 128;
j+=2;
}
var buf = new ArrayBuffer(s.length*2); // 2 bytes for each char
var bufView = new Uint16Array(buf);
for (var i=0, strLen=s.length; i < strLen; i++) {
bufView[i] = s.charCodeAt(i);
}
return new Uint8Array(ba).buffer;
return buf;
}
export function arrayBufferToText(buffer: ArrayBuffer) {
return String.fromCharCode.apply(null, new Uint8Array(buffer));
return String.fromCharCode.apply(null, new Uint16Array(buffer));
}

@@ -31,3 +31,3 @@ import crypto = require('../lib/');

const m = new Uint8Array(crypto.rsa.padding(data, 30));
const unpad = crypto.rsa.unpadding(m, 30);
const unpad = new Uint8Array(crypto.rsa.unpadding(m, 30));
expect(data).toEqual(unpad)

@@ -148,3 +148,3 @@ expect(() => {

ciphertext,
aesjsctr.encrypt(aesjs.utils.utf8.toBytes(plaintext)).buffer
aesjsctr.encrypt(new Uint8Array(crypto.tools.textToArrayBuffer(plaintext))).buffer
)).toBe(true);

@@ -186,18 +186,9 @@

describe('pbkdf2', () => {
it('pbkdf2-sha256', () => {
const password = '123456';
const salt = 'miku';
const resultA = crypto.tools.arrayBufferToHex(crypto.pbkdf2.sha256(
crypto.tools.textToArrayBuffer(password),
crypto.tools.textToArrayBuffer(salt),
5000,
32
));
describe('tools', () => {
it('text', () => {
const arraybuffer = crypto.tools.textToArrayBuffer('𤭢𐐷');
const resultB = require('crypto').pbkdf2Sync(password, salt, 5000, 32, 'sha256').toString('hex');
expect(resultA).toEqual(resultB);
const text = crypto.tools.arrayBufferToText(arraybuffer);
expect(text).toEqual('𤭢𐐷');
})
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc