# HG changeset patch # User Laman # Date 2019-06-29 16:42:59 # Node ID f425e00a94c63fe2f0b57352d485cf12e826992e # Parent 9f2498ffdd4e9aa540bde66155a49e29a0305df0 bundling with Rollup diff --git a/crypto.html b/dist/crypto.html rename from crypto.html rename to dist/crypto.html --- a/crypto.html +++ b/dist/crypto.html @@ -1,12 +1,12 @@ - - + + diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,8 @@ +module.exports = { + input: 'src/main.js', + output: { + file: 'dist/main.js', + format: 'iife', + name: "cryptoJS" + } +}; diff --git a/spec/test/utilSpec.js b/spec/test/utilSpec.js --- a/spec/test/utilSpec.js +++ b/spec/test/utilSpec.js @@ -1,8 +1,8 @@ /* global expect */ describe("Util",function(){ - var util = require("../../util.js"); - var utf=[ // https://tools.ietf.org/html/rfc3629#page-8 + let util=require("../../src/util.js"); + let utf=[ // https://tools.ietf.org/html/rfc3629#page-8 ["",[]], ["abc",[97,98,99]], ["å",[195,165]], diff --git a/blake.js b/src/blake.js rename from blake.js rename to src/blake.js --- a/blake.js +++ b/src/blake.js @@ -12,7 +12,7 @@ function rrot(x,shift){ return ((x>>>shift)|(x<<(32-shift)))&MASK; } -function BLAKE2S(outputLen=32,key=[]){ +export function BLAKE2S(outputLen=32,key=[]){ this._buffer=[]; this._dataLen=[0,0]; // low, high this._outputLen=outputLen; @@ -85,25 +85,8 @@ BLAKE2S.prototype._mix=function(arr,ia,i arr[ia]=a; arr[ib]=b; arr[ic]=c; arr[id]=d; }; -function blake2s(data,outputLen=32,key=[]){ +export function blake2s(data,outputLen=32,key=[]){ let h=new BLAKE2S(outputLen,key); for(let i=0;iacc|b<<(i*8)); } -function bytes2int32s(arr){ +export function bytes2int32s(arr){ let res=[]; for(let i=0;iacc.concat(bytes)); } -function bytes2hex(arr){ +export function bytes2hex(arr){ return arr.map(x=>x.toString(16).padStart(2,"0")).join(""); } -function str2utf8(s){ +export function str2utf8(s){ let res=[]; let c=s.codePointAt(0); for(let i=0; c!==undefined; i++,c=s.codePointAt(i)){ @@ -54,7 +54,7 @@ function str2utf8(s){ return res; } -function utf82str(arr){ +export function utf82str(arr){ let res=[]; for(let i=0;iString.fromCodePoint(x)).join(""); } - -if(typeof module!=='undefined'&&module.hasOwnProperty('exports')){ - module.exports.bytes2int32=bytes2int32; - module.exports.bytes2int32s=bytes2int32s; - module.exports.int322bytes=int322bytes; - module.exports.int32s2bytes=int32s2bytes; - module.exports.bytes2hex=bytes2hex; - module.exports.str2utf8=str2utf8; - module.exports.utf82str=utf82str; -}