PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/js/mage/adminhtml/hash.js

https://bitbucket.org/sevenly/magento-ce
JavaScript | 162 lines | 91 code | 18 blank | 53 comment | 27 complexity | 966e0d30a0ae5f49f0d88b854cd03938 MD5 | raw file
  1. /**
  2. * Magento
  3. *
  4. * NOTICE OF LICENSE
  5. *
  6. * This source file is subject to the Academic Free License (AFL 3.0)
  7. * that is bundled with this package in the file LICENSE_AFL.txt.
  8. * It is also available through the world-wide-web at this URL:
  9. * http://opensource.org/licenses/afl-3.0.php
  10. * If you did not receive a copy of the license and are unable to
  11. * obtain it through the world-wide-web, please send an email
  12. * to license@magentocommerce.com so we can send you a copy immediately.
  13. *
  14. * DISCLAIMER
  15. *
  16. * Do not edit or add to this file if you wish to upgrade Magento to newer
  17. * versions in the future. If you wish to customize Magento for your
  18. * needs please refer to http://www.magentocommerce.com for more information.
  19. *
  20. * @category Mage
  21. * @package Mage_Adminhtml
  22. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  23. * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
  24. */
  25. /*
  26. * Caudium - An extensible World Wide Web server
  27. * Copyright C 2002 The Caudium Group
  28. *
  29. * This program is free software; you can redistribute it and/or
  30. * modify it under the terms of the GNU General Public License as
  31. * published by the Free Software Foundation; either version 2 of the
  32. * License, or (at your option) any later version.
  33. *
  34. * This program is distributed in the hope that it will be useful, but
  35. * WITHOUT ANY WARRANTY; without even the implied warranty of
  36. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  37. * General Public License for more details.
  38. *
  39. * You should have received a copy of the GNU General Public License
  40. * along with this program; if not, write to the Free Software
  41. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  42. *
  43. */
  44. /*
  45. * base64.js - a JavaScript implementation of the base64 algorithm,
  46. * (mostly) as defined in RFC 2045.
  47. *
  48. * This is a direct JavaScript reimplementation of the original C code
  49. * as found in the Exim mail transport agent, by Philip Hazel.
  50. *
  51. * $Id: base64.js,v 1.7 2002/07/16 17:21:23 kazmer Exp $
  52. *
  53. */
  54. function encode_base64( what )
  55. {
  56. var base64_encodetable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  57. var result = "";
  58. var len = what.length;
  59. var x, y;
  60. var ptr = 0;
  61. while( len-- > 0 )
  62. {
  63. x = what.charCodeAt( ptr++ );
  64. result += base64_encodetable.charAt( ( x >> 2 ) & 63 );
  65. if( len-- <= 0 )
  66. {
  67. result += base64_encodetable.charAt( ( x << 4 ) & 63 );
  68. result += "==";
  69. break;
  70. }
  71. y = what.charCodeAt( ptr++ );
  72. result += base64_encodetable.charAt( ( ( x << 4 ) | ( ( y >> 4 ) & 15 ) ) & 63 );
  73. if ( len-- <= 0 )
  74. {
  75. result += base64_encodetable.charAt( ( y << 2 ) & 63 );
  76. result += "=";
  77. break;
  78. }
  79. x = what.charCodeAt( ptr++ );
  80. result += base64_encodetable.charAt( ( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 63 );
  81. result += base64_encodetable.charAt( x & 63 );
  82. }
  83. return result;
  84. }
  85. function decode_base64( what )
  86. {
  87. var base64_decodetable = new Array (
  88. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  89. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
  90. 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63,
  91. 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, 255, 255, 255,
  92. 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  93. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255,
  94. 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  95. 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 255, 255, 255, 255, 255
  96. );
  97. var result = "";
  98. var len = what.length;
  99. var x, y;
  100. var ptr = 0;
  101. while( !isNaN( x = what.charCodeAt( ptr++ ) ) )
  102. {
  103. if( x == 13 || x == 10 )
  104. continue;
  105. if( ( x > 127 ) || (( x = base64_decodetable[x] ) == 255) )
  106. return false;
  107. if( ( isNaN( y = what.charCodeAt( ptr++ ) ) ) || (( y = base64_decodetable[y] ) == 255) )
  108. return false;
  109. result += String.fromCharCode( (x << 2) | (y >> 4) );
  110. if( (x = what.charCodeAt( ptr++ )) == 61 )
  111. {
  112. if( (what.charCodeAt( ptr++ ) != 61) || (!isNaN(what.charCodeAt( ptr ) ) ) )
  113. return false;
  114. }
  115. else
  116. {
  117. if( ( x > 127 ) || (( x = base64_decodetable[x] ) == 255) )
  118. return false;
  119. result += String.fromCharCode( (y << 4) | (x >> 2) );
  120. if( (y = what.charCodeAt( ptr++ )) == 61 )
  121. {
  122. if( !isNaN(what.charCodeAt( ptr ) ) )
  123. return false;
  124. }
  125. else
  126. {
  127. if( (y > 127) || ((y = base64_decodetable[y]) == 255) )
  128. return false;
  129. result += String.fromCharCode( (x << 6) | y );
  130. }
  131. }
  132. }
  133. return result;
  134. }
  135. function wrap76( what )
  136. {
  137. var result = "";
  138. var i;
  139. for(i=0; i < what.length; i+=76)
  140. {
  141. result += what.substring(i, i+76) + String.fromCharCode(13) + String.fromCharCode(10);
  142. }
  143. return result;
  144. }