hash.d.ts 2.3 KB

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