sjcl icon indicating copy to clipboard operation
sjcl copied to clipboard

namespace conflicts

Open amnond opened this issue 10 years ago • 2 comments

When using the minified sjcl.js file, it appears the library is using a global variable named t.

To reproduce, open the following in a browser (assuming sjcl.js is on the same directory)

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./sjcl.js"></script>
</head>
<body>
</body>
</html>

Then in the browser console try the following:

sjcl.encrypt("this","that") {"iv":"NpkCTgNBgTFazbha/fgg8A==","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"oZ6lThzs6hg=","ct":"icDzqhJv5gWSMhP0"}

t={} Object {}

sjcl.encrypt("this","that") TypeError: Cannot read property 'length' of undefined

amnond avatar Oct 07 '14 19:10 amnond

This is most likely caused by the closure compiler who assigns true/false values to constants for faster referencing.

an easy fix would be adding a wrapper function around the full compiled library which just returns sjcl (and assigns it too).

Nilos avatar Oct 30 '14 15:10 Nilos

I just noticed the same thing 🙈 Will this be fixed at some point? Its been over 5 years now ...

fq-selbach avatar Apr 01 '20 13:04 fq-selbach