PageRenderTime 18ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
ActionScript | 71 lines | 52 code | 8 blank | 11 comment | 3 complexity | 0ebfb489fe55ae16f91a6ee69fb5b005 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /**
  2. * SHABase
  3. *
  4. * An ActionScript 3 abstract class for the SHA family of hash functions
  5. * Copyright (c) 2007 Henri Torgemane
  6. *
  7. * See LICENSE.txt for full license information.
  8. */
  9. package com.hurlant.crypto.hash
  10. {
  11. import flash.utils.ByteArray;
  12. import flash.utils.Endian;
  13. public class SHABase implements IHash
  14. {
  15. public function SHABase() { }
  16. public var pad_size:int = 40;
  17. public function getInputSize():uint
  18. {
  19. return 64;
  20. }
  21. public function getHashSize():uint
  22. {
  23. return 0;
  24. }
  25. public function getPadSize():int
  26. {
  27. return pad_size;
  28. }
  29. public function hash(src:ByteArray):ByteArray
  30. {
  31. var savedLength:uint = src.length;
  32. var savedEndian:String = src.endian;
  33. src.endian = Endian.BIG_ENDIAN;
  34. var len:uint = savedLength *8;
  35. // pad to nearest int.
  36. while (src.length%4!=0) {
  37. src[src.length]=0;
  38. }
  39. // convert ByteArray to an array of uint
  40. src.position=0;
  41. var a:Array = [];
  42. for (var i:uint=0;i<src.length;i+=4) {
  43. a.push(src.readUnsignedInt());
  44. }
  45. var h:Array = core(a, len);
  46. var out:ByteArray = new ByteArray;
  47. var words:uint = getHashSize()/4;
  48. for (i=0;i<words;i++) {
  49. out.writeUnsignedInt(h[i]);
  50. }
  51. // unpad, to leave the source untouched.
  52. src.length = savedLength;
  53. src.endian = savedEndian;
  54. return out;
  55. }
  56. protected function core(x:Array, len:uint):Array {
  57. return null;
  58. }
  59. public function toString():String {
  60. return "sha";
  61. }
  62. }
  63. }