hash.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. declare var hash: Hash;
  2. declare module "hash.js" {
  3. export = hash;
  4. }
  5. interface BlockHash<T> {
  6. hmacStrength: number
  7. padLength: number
  8. endian: 'big' | 'little'
  9. }
  10. interface MessageDigest<T> {
  11. blockSize: number
  12. outSize: number
  13. update(msg: any, enc?: 'hex'): T
  14. digest(): number[]
  15. digest(enc: 'hex'): string
  16. }
  17. interface Hash {
  18. hmac: HmacConstructor
  19. ripemd: RipemdSet
  20. ripemd160: Ripemd160Constructor
  21. sha: ShaSet
  22. sha1: Sha1Constructor
  23. sha224: Sha224Constructor
  24. sha256: Sha256Constructor
  25. sha384: Sha384Constructor
  26. sha512: Sha512Constructor
  27. utils: Utils
  28. }
  29. interface Utils {
  30. toArray(msg: any, enc: 'hex'): Array<number>
  31. toHex(msg: any): string
  32. }
  33. interface RipemdSet {
  34. ripemd160: Ripemd160Constructor
  35. }
  36. interface ShaSet {
  37. sha1: Sha1Constructor
  38. sha224: Sha224Constructor
  39. sha256: Sha256Constructor
  40. sha384: Sha384Constructor
  41. sha512: Sha512Constructor
  42. }
  43. interface HmacConstructor { (hash: BlockHash<any>, key: any, enc?: 'hex'): Hmac }
  44. interface Ripemd160Constructor { (): Ripemd160 }
  45. interface Sha1Constructor { (): Sha1; }
  46. interface Sha224Constructor { (): Sha224; }
  47. interface Sha256Constructor { (): Sha256; }
  48. interface Sha384Constructor { (): Sha384; }
  49. interface Sha512Constructor { (): Sha512; }
  50. interface Hmac extends MessageDigest<Hmac> {
  51. blockSize: 512
  52. outSize: 160
  53. }
  54. interface Ripemd160 extends BlockHash<Ripemd160>, MessageDigest<Ripemd160> {
  55. blockSize: 512
  56. hmacStrength: 192
  57. outSize: 160
  58. padLength: 64
  59. endian: 'little'
  60. }
  61. interface Sha1 extends BlockHash<Sha1>, MessageDigest<Sha1> {
  62. blockSize: 512
  63. hmacStrength: 80
  64. outSize: 160
  65. padLength: 64
  66. endian: 'big'
  67. }
  68. interface Sha224 extends BlockHash<Sha224>, MessageDigest<Sha224> {
  69. blockSize: 512
  70. hmacStrength: 192
  71. outSize: 224
  72. padLength: 64
  73. endian: 'big'
  74. }
  75. interface Sha256 extends BlockHash<Sha256>, MessageDigest<Sha256> {
  76. blockSize: 512
  77. hmacStrength: 192
  78. outSize: 256
  79. padLength: 64
  80. endian: 'big'
  81. }
  82. interface Sha384 extends BlockHash<Sha384>, MessageDigest<Sha384> {
  83. blockSize: 1024
  84. hmacStrength: 192
  85. outSize: 384
  86. padLength: 128
  87. endian: 'big'
  88. }
  89. interface Sha512 extends BlockHash<Sha512>, MessageDigest<Sha512> {
  90. blockSize: 1024
  91. hmacStrength: 192
  92. outSize: 512
  93. padLength: 128
  94. endian: 'big'
  95. }