jsencrypt.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. declare class JSEncrypt{
  2. constructor(options?);
  3. /**
  4. * Method to set the rsa key parameter (one method is enough to set both the public
  5. * and the private key, since the private key contains the public key paramenters)
  6. * Log a warning if logs are enabled
  7. * @param {Object|string} key the pem encoded string or an object (with or without header/footer)
  8. * @public
  9. */
  10. setKey(key: string);
  11. /**
  12. * Proxy method for setKey, for api compatibility
  13. * @see setKey
  14. * @public
  15. */
  16. setPrivateKey(privkey: string);
  17. /**
  18. * Proxy method for setKey, for api compatibility
  19. * @see setKey
  20. * @public
  21. */
  22. setPublicKey(pubkey: string);
  23. /**
  24. * Proxy method for RSAKey object's decrypt, decrypt the string using the private
  25. * components of the rsa key object. Note that if the object was not set will be created
  26. * on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
  27. * @param {string} string base64 encoded crypted string to decrypt
  28. * @return {string} the decrypted string
  29. * @public
  30. */
  31. decrypt(string): string|false;
  32. /**
  33. * Proxy method for RSAKey object's encrypt, encrypt the string using the public
  34. * components of the rsa key object. Note that if the object was not set will be created
  35. * on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
  36. * @param {string} string the string to encrypt
  37. * @return {string} the encrypted string encoded in base64
  38. * @public
  39. */
  40. encrypt(string) :string|false;
  41. /**
  42. * Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
  43. * will be created and returned
  44. * @param {callback} [cb] the callback to be called if we want the key to be generated
  45. * in an async fashion
  46. * @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
  47. * @public
  48. */
  49. getKey(cb);
  50. /**
  51. * Returns the pem encoded representation of the private key
  52. * If the key doesn't exists a new key will be created
  53. * @returns {string} pem encoded representation of the private key WITH header and footer
  54. * @public
  55. */
  56. getPrivateKey();
  57. /**
  58. * Returns the pem encoded representation of the private key
  59. * If the key doesn't exists a new key will be created
  60. * @returns {string} pem encoded representation of the private key WITHOUT header and footer
  61. * @public
  62. */
  63. getPrivateKeyB64();
  64. /**
  65. * Returns the pem encoded representation of the public key
  66. * If the key doesn't exists a new key will be created
  67. * @returns {string} pem encoded representation of the public key WITH header and footer
  68. * @public
  69. */
  70. getPublicKey();
  71. /**
  72. * Returns the pem encoded representation of the public key
  73. * If the key doesn't exists a new key will be created
  74. * @returns {string} pem encoded representation of the public key WITHOUT header and footer
  75. * @public
  76. */
  77. getPublicKeyB64();
  78. }