bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.19k stars 988 forks source link

namespace conflicts #196

Open amnond opened 10 years ago

amnond commented 10 years ago

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

Nilos commented 10 years ago

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).

fq-selbach commented 4 years ago

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