perkeep/server/camlistored/ui/zembed_Crypto.js.go

7 lines
6.3 KiB
Go
Raw Normal View History

// THIS FILE IS AUTO-GENERATED FROM Crypto.js
// DO NOT EDIT.
package ui
func init() {
Files.Add("Crypto.js", "// From http://code.google.com/p/crypto-js/\r\n// License: http://www.opensource.org/licenses/bsd-license.php\r\n//\r\n// Copyright (c) 2009, Jeff Mott. All rights reserved.\r\n// \r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are met:\r\n// \r\n// Redistributions of source code must retain the above copyright notice, this\r\n// list of conditions and the following disclaimer. Redistributions in binary\r\n// form must reproduce the above copyright notice, this list of conditions and\r\n// the following disclaimer in the documentation and/or other materials provided\r\n// with the distribution. Neither the name Crypto-JS nor the names of its\r\n// contributors may be used to endorse or promote products derived from this\r\n// software without specific prior written permission. THIS SOFTWARE IS PROVIDED\r\n// BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED\r\n// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r\n// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\r\n// EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r\n// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r\n// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r\n// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r\n// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n\r\nif (typeof Crypto == \"undefined\" || ! Crypto.util)\r\n{\r\n(function(){\r\n\r\nvar base64map = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\r\n\r\n// Global Crypto object\r\nvar Crypto = window.Crypto = {};\r\n\r\n// Crypto utilities\r\nvar util = Crypto.util = {\r\n\r\n\t// Bit-wise rotate left\r\n\trotl: function (n, b) {\r\n\t\treturn (n << b) | (n >>> (32 - b));\r\n\t},\r\n\r\n\t// Bit-wise rotate right\r\n\trotr: function (n, b) {\r\n\t\treturn (n << (32 - b)) | (n >>> b);\r\n\t},\r\n\r\n\t// Swap big-endian to little-endian and vice versa\r\n\tendian: function (n) {\r\n\r\n\t\t// If number given, swap endian\r\n\t\tif (n.constructor == Number) {\r\n\t\t\treturn util.rotl(n, 8) & 0x00FF00FF |\r\n\t\t\t util.rotl(n, 24) & 0xFF00FF00;\r\n\t\t}\r\n\r\n\t\t// Else, assume array and swap all items\r\n\t\tfor (var i = 0; i < n.length; i++)\r\n\t\t\tn[i] = util.endian(n[i]);\r\n\t\treturn n;\r\n\r\n\t},\r\n\r\n\t// Generate an array of any length of random bytes\r\n\trandomBytes: function (n) {\r\n\t\tfor (var bytes = []; n > 0; n--)\r\n\t\t\tbytes.push(Math.floor(Math.random() * 256));\r\n\t\treturn bytes;\r\n\t},\r\n\r\n\t// Convert a byte array to big-endian 32-bit words\r\n\tbytesToWords: function (bytes) {\r\n\t\tfor (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)\r\n\t\t\twords[b >>> 5] |= bytes[i] << (24 - b % 32);\r\n\t\treturn words;\r\n\t},\r\n\r\n\t// Convert big-endian 32-bit words to a byte array\r\n\twordsToBytes: function (words) {\r\n\t\tfor (var bytes = [], b = 0; b < words.length * 32; b += 8)\r\n\t\t\tbytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);\r\n\t\treturn bytes;\r\n\t},\r\n\r\n\t// Convert a byte array to a hex string\r\n\tbytesToHex: function (bytes) {\r\n\t\tfor (var hex = [], i = 0; i < bytes.length; i++) {\r\n\t\t\thex.push((bytes[i] >>> 4).toString(16));\r\n\t\t\thex.push((bytes[i] & 0xF).toString(16));\r\n\t\t}\r\n\t\treturn hex.join(\"\");\r\n\t},\r\n\r\n\t// Convert a hex string to a byte array\r\n\thexToBytes: function (hex) {\r\n\t\tfor (var bytes = [], c = 0; c < hex.length; c += 2)\r\n\t\t\tbytes.push(parseInt(hex.substr(c, 2), 16));\r\n\t\treturn bytes;\r\n\t},\r\n\r\n\t// Convert a byte array to a base-64 string\r\n\tbytesToBase64: function (bytes) {\r\n\r\n\t\t// Use browser-native function if it exists\r\n\t\tif (typeof bto
}