2

I have working algorithm on my own project and I need it to be uploaded on jsfiddle and working as expected. The bad thing is I have no idea how to use crypto module to work there.

this.getOffset = function(forcedOffset){
    return Bluebird.try(function () {
        if (forcedOffset != undefined) return forcedOffset;

        return CryptoJS.randomBytes(4);
    }).then(function (randomBytes) {
        var random = Number.parseInt(randomBytes.toString('hex'), 16) / 4294967295;
        var maxVal = 1000000;
        return Math.floor(random * maxVal);
    });
};

and for my project I'm just requiring it, but how to handle this situation here?

2
  • 1
    Load it as an external resource from a CDN. Commented Feb 16, 2018 at 18:35
  • 1
    and where can I find it uploaded to CDN? because i tried to load this one crypto-js but didn't figured out how to use it. Commented Feb 16, 2018 at 18:37

2 Answers 2

1

You need to find it on a CDN and load it.

After googling "cryptojs cdn" i found this list of the resources

https://cdnjs.com/libraries/crypto-js

Sign up to request clarification or add additional context in comments.

2 Comments

and how to use it loading this lib ? how the variable will be called?
documentation of what? I just can't understand how to use functions of this module on jsfiddle.
0

crypto-js can be found here. Using UNPKG you can load any file from any package following this pattern

https://unpkg.com/:package@:version/:file

So, if you add

https://unpkg.com/[email protected]/

Then you'll get this (as shown in the next image)

UNPKG npm package in JSFiddle

If you specify the index.js file

https://unpkg.com/[email protected]/index.js

Then you'll get this (as shown in the next image)

JSFiddle with npm packages

You'll then be able to use it in your fiddles by adding the Resources you want to.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.