md5.d.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. interface HasherState {
  2. buffer: string;
  3. buflen: number;
  4. length: number;
  5. state: number[];
  6. }
  7. export declare class Md5 {
  8. /**
  9. * Hash a UTF-8 string on the spot
  10. * @param str String to hash
  11. * @param raw Whether to return the value as an `Int32Array`
  12. */
  13. static hashStr(str: string, raw?: false): string;
  14. static hashStr(str: string, raw: true): Int32Array;
  15. /**
  16. * Hash a ASCII string on the spot
  17. * @param str String to hash
  18. * @param raw Whether to return the value as an `Int32Array`
  19. */
  20. static hashAsciiStr(str: string, raw?: false): string;
  21. static hashAsciiStr(str: string, raw: true): Int32Array;
  22. private static stateIdentity;
  23. private static buffer32Identity;
  24. private static hexChars;
  25. private static hexOut;
  26. private static onePassHasher;
  27. private static _hex;
  28. private static _md5cycle;
  29. private _dataLength;
  30. private _bufferLength;
  31. private _state;
  32. private _buffer;
  33. private _buffer8;
  34. private _buffer32;
  35. constructor();
  36. /**
  37. * Initialise buffer to be hashed
  38. */
  39. start(): this;
  40. /**
  41. * Append a UTF-8 string to the hash buffer
  42. * @param str String to append
  43. */
  44. appendStr(str: string): this;
  45. /**
  46. * Append an ASCII string to the hash buffer
  47. * @param str String to append
  48. */
  49. appendAsciiStr(str: string): this;
  50. /**
  51. * Append a byte array to the hash buffer
  52. * @param input array to append
  53. */
  54. appendByteArray(input: Uint8Array): this;
  55. /**
  56. * Get the state of the hash buffer
  57. */
  58. getState(): HasherState;
  59. /**
  60. * Override the current state of the hash buffer
  61. * @param state New hash buffer state
  62. */
  63. setState(state: HasherState): void;
  64. /**
  65. * Hash the current state of the hash buffer and return the result
  66. * @param raw Whether to return the value as an `Int32Array`
  67. */
  68. end(raw?: boolean): string | Int32Array | undefined;
  69. }
  70. export {};