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

kor-4096

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kor-4096 - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

src/util.ts

22

index.js

@@ -1,5 +0,19 @@

var ChainHash = require("chain-hash");
import KorEncode from "./srtc/index";
var chain = new ChainHash("test");
console.log(chain.GetKey);
console.log(chain.GetValidate);
let plain = "0123456789asdf";
let kor = korEncode.encode(plain);
console.log(kor); //값뽅뉸벚곟찁
let hex = korEncode.encode(kor);
console.log(hex); //0123456789asdf
plain = "7a538344c200b87ed788809520bc82c4c8a9519235323f9b2a8572e2ef489966";
kor = korEncode.encode(plain);
console.log(kor); //뎥뾃끌븀랇쫗뒈법긋좂롌쒩넙븵꼣쮛꺨셲먮쭈떖밆찂
hex = korEncode.encode(kor);
console.log(hex); //7a538344c200b87ed788809520bc82c4c8a9519235323f9b2a8572e2ef489966
plain = "cf90b67643c7b1a8930acfe64549370f207b54aabdcc2ce5e1173afac24458d96b37960e8fee639c9a51c76e37744d261e332fb5b8c3f543bd72a4fabd83ce7f";
kor = korEncode.encode(plain);
console.log(kor); //룹벶덤뿇뜚쒓견쯦끔씷곲뱻녊욽룂죥먑쌺뮬비농앫꽹숎듾쩣뗉왑롶쨷덄줦귣뼯띛쓃뭔뾽댪샺럘뿎걿찁
hex = korEncode.encode(kor);
console.log(hex); //cf90b67643c7b1a8930acfe64549370f207b54aabdcc2ce5e1173afac24458d96b37960e8fee639c9a51c76e37744d261e332fb5b8c3f543bd72a4fabd83ce7f

3

package.json
{
"name": "kor-4096",
"description": "kor 4096 package",
"version": "0.2.0",
"version": "0.2.1",
"main": "./dist/hexKor.js",

@@ -19,2 +19,3 @@ "types": "./dist/hexKor.d.ts",

"dev": "nodemon --exec ts-node ./src/index.ts",
"dev:test": "nodemon --exec ts-node ./index.js",
"build": "tsc",

@@ -21,0 +22,0 @@ "product": "node ./dist/index.js"

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

import { isBuffer } from "./util";
export default class Generator {

@@ -8,11 +10,7 @@ private static StartCode: number = 44032;

let number = parseInt(hex.substr(i * 3, 3), 16);
result += String.fromCharCode(
this.StartCode + (i % 2 == 0 ? number : number + this.blockSize)
);
result += String.fromCharCode(this.StartCode + (i % 2 == 0 ? number : number + this.blockSize));
}
if (hex.length % 3 == 1 || hex.length % 3 == 2) {
let padding = String.fromCharCode(
this.StartCode + this.blockSize * 2 + (3 - (hex.length % 3))
);
let padding = String.fromCharCode(this.StartCode + this.blockSize * 2 + (3 - (hex.length % 3)));
result += padding;

@@ -24,14 +22,15 @@ }

public static kor2Hex(kor: string | Buffer): string {
if (Buffer.isBuffer(kor)) kor = kor.toString("hex");
let stringData = kor as string;
if (isBuffer(kor)) stringData = (kor as Buffer).toString("hex");
let padding: number = 0;
// console.log(kor.charCodeAt(kor.length - 1));
if (kor.charCodeAt(kor.length - 1) > this.blockSize * 2 + this.StartCode) {
padding = kor.charCodeAt(kor.length - 1) - this.StartCode - this.blockSize * 2;
kor = kor.slice(0, kor.length - 1);
if (stringData.charCodeAt(stringData.length - 1) > this.blockSize * 2 + this.StartCode) {
padding = stringData.charCodeAt(stringData.length - 1) - this.StartCode - this.blockSize * 2;
stringData = stringData.slice(0, stringData.length - 1);
}
let result = "";
for (var i = 0; i < kor.length; i++) {
let code: number = kor[i].charCodeAt(0);
for (var i = 0; i < stringData.length; i++) {
let code: number = stringData[i].charCodeAt(0);
let number = code - this.StartCode;

@@ -77,5 +76,7 @@ if (i % 2 == 1) number -= this.blockSize;

public static encode(plain: string | Buffer | number) {
if (Buffer.isBuffer(plain)) plain = plain.toString("hex");
else if (typeof plain == "number") plain = plain.toString(16);
return this.hex2Kor(plain);
let plainString = plain as string;
if (isBuffer(plain)) plainString = (plain as Buffer).toString("hex");
else if (typeof plain == "number") plainString = plain.toString(16);
return this.hex2Kor(plainString);
}

@@ -89,3 +90,3 @@ public static encodeArray(plainList: any[]): string[] {

public static decode(kor64: string | Buffer | number) {
if (Buffer.isBuffer(kor64)) kor64 = kor64.toString("hex");
if (isBuffer(kor64)) kor64 = (kor64 as Buffer).toString("hex");
else if (typeof kor64 == "number") kor64 = kor64.toString(16);

@@ -92,0 +93,0 @@ return this.kor2Hex(kor64);

import korEncode from "./hexKor";
let text =
"CF90B67643C7B1A8930ACFE64549370F207B54AABDCC2CE5E1173AFAC24458D96B37960E8FEE639C9A51C76E37744D261E332FB5B8C3F543BD72A4FABD83CE7F";
console.log(text);
let kor = korEncode.encode(text);
console.log(kor);
let hex = korEncode.decode(kor);
console.log(hex);
let plain = "0123456789asdf";
let kor = korEncode.encode(plain);
console.log(plain, kor); //값뽅뉸벚곟찁
let hex = korEncode.encode(kor);
console.log(kor, hex); //0123456789asdf
// console.log(hex);
// let hexList = [0, "a", 1024, "111111111111", "a0", "a000", "0", 4096, "000", "1234567890abcde0987654321", 123456789];
// console.log(hexList);
// let encList = korEncode.encodeArray(hexList);
// console.log(encList);
// let decList = korEncode.decodeArray(encList);
// console.log(decList);
plain = "7a538344c200b87ed788809520bc82c4c8a9519235323f9b2a8572e2ef489966";
kor = korEncode.encode(plain);
console.log(plain, kor); //뎥뾃끌븀랇쫗뒈법긋좂롌쒩넙븵꼣쮛꺨셲먮쭈떖밆찂
hex = korEncode.encode(kor);
console.log(kor, hex); //7a538344c200b87ed788809520bc82c4c8a9519235323f9b2a8572e2ef489966
// let korList = [];
// for (var i = 0; i < hexList.length; i++) {
// korList.push(hexKor.hex2Kor(hexList[i]));
// console.log(korList[i]);
// console.log(hexList[i]);
// console.log(hexKor.kor2Hex(korList[i]));
// console.log("\n");
// }
// let dec = 1234567891234;
// let kor = korEncode.encode(dec);
// console.log(dec);
// console.log(korEncode.decode(kor));
//console.log(kor64.Buf);
plain = "cf90b67643c7b1a8930acfe64549370f207b54aabdcc2ce5e1173afac24458d96b37960e8fee639c9a51c76e37744d261e332fb5b8c3f543bd72a4fabd83ce7f";
kor = korEncode.encode(plain);
console.log(plain, kor); //룹벶덤뿇뜚쒓견쯦끔씷곲뱻녊욽룂죥먑쌺뮬비농앫꽹숎듾쩣뗉왑롶쨷덄줦귣뼯띛쓃뭔뾽댪샺럘뿎걿찁
hex = korEncode.encode(kor);
console.log(kor, hex); //cf90b67643c7b1a8930acfe64549370f207b54aabdcc2ce5e1173afac24458d96b37960e8fee639c9a51c76e37744d261e332fb5b8c3f543bd72a4fabd83ce7f
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