trait Crypto extends Object

The crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign and verify functions.

Annotations
@JSType() @native()
See also

https://nodejs.org/dist/latest-v7.x/docs/api/crypto.html#crypto_crypto

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Crypto
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def checkPrime(candidate: |[|[|[|[|[ArrayBuffer, SharedArrayBuffer], TypedArray[_, _]], Buffer], DataView], BigInt], options: CheckPrimeOptions, callback: Callback1[Boolean]): Unit
  6. def checkPrimeSync(candidate: |[|[|[|[|[ArrayBuffer, SharedArrayBuffer], TypedArray[_, _]], Buffer], DataView], BigInt]): Boolean
  7. def checkPrimeSync(candidate: |[|[|[|[|[ArrayBuffer, SharedArrayBuffer], TypedArray[_, _]], Buffer], DataView], BigInt], options: CheckPrimeOptions): Boolean
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  9. def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike): Cipher
  10. def createCipheriv(algorithm: String, key: KeyObject, iv: String): Cipher
  11. def createCipheriv(algorithm: String, key: KeyObject, iv: BufferLike, options: TransformOptions): Cipher
  12. def createCipheriv(algorithm: String, key: KeyObject, iv: String, options: TransformOptions): Cipher
  13. def createCipheriv(algorithm: String, key: BufferLike, iv: BufferLike): Cipher
  14. def createCipheriv(algorithm: String, key: BufferLike, iv: String, options: TransformOptions): Cipher
  15. def createCipheriv(algorithm: String, key: String, iv: BufferLike): Cipher
  16. def createCipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Cipher
  17. def createDecipheriv(algorithm: String, key: KeyObject, iv: BufferLike): Decipher
  18. def createDecipheriv(algorithm: String, key: KeyObject, iv: String): Decipher
  19. def createDecipheriv(algorithm: String, key: KeyObject, iv: BufferLike, options: TransformOptions): Decipher
  20. def createDecipheriv(algorithm: String, key: KeyObject, iv: String, options: TransformOptions): Decipher
  21. def createDecipheriv(algorithm: String, key: BufferLike, iv: BufferLike): Decipher
  22. def createDecipheriv(algorithm: String, key: BufferLike, iv: String): Decipher
  23. def createDecipheriv(algorithm: String, key: String, iv: BufferLike, options: TransformOptions): Decipher
  24. def createDecipheriv(algorithm: String, key: String, iv: String, options: TransformOptions): Decipher
  25. def createDiffieHellman(primeLength: Int, generator: Int): DiffieHellman
  26. def createDiffieHellman(prime: BufferLike, generator: BufferLike): DiffieHellman
  27. def createDiffieHellman(prime: BufferLike, generator: Int): DiffieHellman
  28. def createDiffieHellman(prime: BufferLike, generator: String, generatorEncoding: String): DiffieHellman
  29. def createDiffieHellman(prime: String, primeEncoding: String, generator: String, generatorEncoding: String): DiffieHellman
  30. def createDiffieHellman(prime: String, primeEncoding: String, generator: BufferLike): DiffieHellman
  31. def createDiffieHellman(prime: String, primeEncoding: String, generator: Int): DiffieHellman
  32. def createDiffieHellmanGroup(name: String): DiffieHellman
  33. def createECDH(curveName: String): ECDH
  34. def createHash(algorithm: String): Hash
  35. def createHash(algorithm: String, options: CreateHashOptions): Hash

    Creates and returns a Hash object that can be used to generate hash digests using the given algorithm.

    Creates and returns a Hash object that can be used to generate hash digests using the given algorithm.

    The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list-message-digest-algorithms will display the available digest algorithms.

    algorithm

    the given algorithm (e.g. 'sha256', 'sha512')

  36. def createHmac(algorithm: String, key: KeyObject): Hmac
  37. def createHmac(algorithm: String, key: KeyObject, options: TransformOptions): Hmac
  38. def createHmac(algorithm: String, key: BufferLike): Hmac
  39. def createHmac(algorithm: String, key: String): Hmac
  40. def createHmac(algorithm: String, key: BufferLike, options: TransformOptions): Hmac
  41. def createHmac(algorithm: String, key: String, options: TransformOptions): Hmac

    Creates and returns an Hmac object that uses the given algorithm and key.

    Creates and returns an Hmac object that uses the given algorithm and key.

    The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list-message-digest-algorithms will display the available digest algorithms.

    algorithm

    the given algorithm (e.g. 'sha256', 'sha512')

    key

    The key is the HMAC key used to generate the cryptographic HMAC hash.

  42. def createPrivateKey(key: CreatePrivateKeyOptions): KeyObject
  43. def createPrivateKey(key: Buffer): KeyObject
  44. def createPrivateKey(key: String): KeyObject
  45. def createPublicKey(key: CreatePublicKeyOptions): KeyObject
  46. def createPublicKey(key: KeyObject): KeyObject
  47. def createPublicKey(key: Buffer): KeyObject
  48. def createPublicKey(key: String): KeyObject
  49. def createSecretKey(key: Buffer): KeyObject
  50. def createSign(algorithm: String): Sign
  51. def createSign(algorithm: String, options: WritableOptions): Sign

    Creates and returns a Sign object that uses the given algorithm.

    Creates and returns a Sign object that uses the given algorithm. On recent OpenSSL releases, openssl list-public-key-algorithms will display the available signing algorithms. One example is 'RSA-SHA256'.

    algorithm

    the given algorithm (e.g. 'RSA-SHA256')

  52. def createVerify(algorithm: String): Verify
  53. def createVerify(algorithm: String, options: WritableOptions): Verify

    Creates and returns a Verify object that uses the given algorithm.

    Creates and returns a Verify object that uses the given algorithm. On recent OpenSSL releases, openssl list-public-key-algorithms will display the available signing algorithms. One example is 'RSA-SHA256'.

    algorithm

    the given algorithm (e.g. 'RSA-SHA256')

  54. def diffieHellman(options: DiffieHellmanOptions): Buffer
  55. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  56. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  57. def generateKey(type: String, options: GenerateKeyOptions, callback: Callback1[KeyObject]): Unit
  58. def generateKeyPair(type: String, options: GenerateKeyPairOptions, callback: Callback2[|[|[String, Buffer], KeyObject], |[|[String, Buffer], KeyObject]]): Unit
  59. def generateKeyPairSync(type: String, options: GenerateKeyPairOptions): KeyPair
  60. def generateKeySync(type: String, options: GenerateKeyOptions): Unit
  61. def generatePrime(size: String, options: GeneratePrimeOptions, callback: Callback1[|[ArrayBuffer, BigInt]]): Unit
  62. def generatePrimeSync(size: String, options: GeneratePrimeOptions): |[ArrayBuffer, BigInt]
  63. def getCipherInfo(nid: Double, options: GetCipherInfoOptions): UndefOr[CipherInfo]
  64. def getCipherInfo(nid: Double): UndefOr[CipherInfo]
  65. def getCipherInfo(name: String, options: GetCipherInfoOptions): UndefOr[CipherInfo]
  66. def getCipherInfo(name: String): UndefOr[CipherInfo]
  67. def getCiphers(): Array[String]

    Returns an array with the names of the supported cipher algorithms.

    Returns an array with the names of the supported cipher algorithms.

    returns

    the names of the supported cipher algorithms. // ['aes-128-cbc', 'aes-128-ccm', ...]

  68. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  69. def getCurves(): Array[String]
  70. def getDiffieHellman(groupName: String): DiffieHellmanGroup
  71. def getFips(): Boolean
  72. def getHashes(): Array[String]
  73. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  74. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  75. def hkdf(digest: String, key: |[|[|[|[|[String, ArrayBuffer], Buffer], TypedArray[_, _]], DataView], KeyObject], salt: |[|[|[|[String, ArrayBuffer], Buffer], TypedArray[_, _]], DataView], info: |[|[|[|[String, ArrayBuffer], Buffer], TypedArray[_, _]], DataView], keylen: Int, callback: Callback1[Buffer]): Unit
  76. def hkdfSync(digest: String, key: |[|[|[|[|[String, ArrayBuffer], Buffer], TypedArray[_, _]], DataView], KeyObject], salt: |[|[|[|[String, ArrayBuffer], Buffer], TypedArray[_, _]], DataView], info: |[|[|[|[String, ArrayBuffer], Buffer], TypedArray[_, _]], DataView], keylen: Int): Buffer
  77. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  78. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  79. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  80. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  81. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  82. def pbkdf2(password: BufferLike, salt: BufferLike, iterations: Int, keylen: Int, digest: String, callback: Callback1[Buffer]): Buffer
  83. def pbkdf2(password: BufferLike, salt: String, iterations: Int, keylen: Int, digest: String, callback: Callback1[Buffer]): Buffer
  84. def pbkdf2(password: String, salt: BufferLike, iterations: Int, keylen: Int, digest: String, callback: Callback1[Buffer]): Buffer
  85. def pbkdf2(password: String, salt: String, iterations: Int, keylen: Int, digest: String, callback: Callback1[Buffer]): Buffer
  86. def pbkdf2Sync(password: BufferLike, salt: BufferLike, iterations: Int, keylen: Int, digest: String): Buffer
  87. def pbkdf2Sync(password: BufferLike, salt: String, iterations: Int, keylen: Int, digest: String): Buffer
  88. def pbkdf2Sync(password: String, salt: BufferLike, iterations: Int, keylen: Int, digest: String): Buffer
  89. def pbkdf2Sync(password: String, salt: String, iterations: Int, keylen: Int, digest: String): Buffer

    Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation.

    Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by digest is applied to derive a key of the requested byte length (keylen) from the password, salt and iterations.

    If an error occurs an Error will be thrown, otherwise the derived key will be returned as a Buffer.

    The iterations argument must be a number set as high as possible. The higher the number of iterations, the more secure the derived key will be, but will take a longer amount of time to complete.

    The salt should also be as unique as possible. It is recommended that the salts are random and their lengths are greater than 16 bytes. See NIST SP 800-132 for details.

    (Doc source: https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest)

  90. def privateDecrypt(privateKey: PrivateDecryptKeyObject, buffer: BufferLike): Buffer
  91. def privateDecrypt(privateKey: Buffer, buffer: BufferLike): Buffer
  92. def privateDecrypt(privateKey: String, buffer: BufferLike): Buffer
  93. def privateEncrypt(privateKey: PrivateEncryptKeyObject, buffer: BufferLike): Buffer
  94. def privateEncrypt(privateKey: Buffer, buffer: BufferLike): Buffer
  95. def privateEncrypt(privateKey: String, buffer: BufferLike): Buffer
  96. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  97. def publicDecrypt(key: PublicDecryptKeyObject, buffer: BufferLike): Buffer
  98. def publicDecrypt(key: Buffer, buffer: BufferLike): Buffer
  99. def publicDecrypt(key: String, buffer: BufferLike): Buffer
  100. def publicEncrypt(key: PublicEncryptKeyObject, buffer: BufferLike): Buffer
  101. def publicEncrypt(key: Buffer, buffer: BufferLike): Buffer
  102. def publicEncrypt(key: String, buffer: BufferLike): Buffer
  103. def randomBytes(size: Int, callback: Callback1[Buffer]): Unit
  104. def randomBytes(size: Int): Buffer
  105. def randomFill[T <: TypedArray[_, T]](buffer: T, callback: Callback1[T]): T
  106. def randomFill[T <: TypedArray[_, T]](buffer: T, offset: Int, callback: Callback1[T]): T
  107. def randomFill[T <: TypedArray[_, T]](buffer: T, offset: Int, size: Int, callback: Callback1[T]): T
  108. def randomFill(buffer: DataView, callback: Callback1[DataView]): DataView
  109. def randomFill(buffer: DataView, offset: Int, callback: Callback1[DataView]): DataView
  110. def randomFill(buffer: DataView, offset: Int, size: Int, callback: Callback1[DataView]): DataView
  111. def randomFill(buffer: Buffer, callback: Callback1[Buffer]): Buffer
  112. def randomFill(buffer: Buffer, offset: Int, callback: Callback1[Buffer]): Buffer
  113. def randomFill(buffer: Buffer, offset: Int, size: Int, callback: Callback1[Buffer]): Buffer
  114. def randomFillSync[T <: TypedArray[_, T]](buffer: T): T
  115. def randomFillSync[T <: TypedArray[_, T]](buffer: T, offset: Int): T
  116. def randomFillSync[T <: TypedArray[_, T]](buffer: T, offset: Int, size: Int): T
  117. def randomFillSync(buffer: DataView): DataView
  118. def randomFillSync(buffer: DataView, offset: Int): DataView
  119. def randomFillSync(buffer: DataView, offset: Int, size: Int): DataView
  120. def randomFillSync(buffer: Buffer): Buffer
  121. def randomFillSync(buffer: Buffer, offset: Int): Buffer
  122. def randomFillSync(buffer: Buffer, offset: Int, size: Int): Buffer
  123. def randomInt(min: Int, max: Int, callback: Callback1[Int]): Unit
  124. def randomInt(min: Int, max: Int): Int
  125. def randomInt(max: Int, callback: Callback1[Int]): Unit
  126. def randomInt(max: Int): Int
  127. def randomUUID(): String
  128. def randomUUID(options: RandomUUIDOptions): String
  129. def scrypt(password: BufferLike, salt: BufferLike, keylen: Int, callback: Callback1[Buffer]): Unit
  130. def scrypt(password: BufferLike, salt: String, keylen: Int, callback: Callback1[Buffer]): Unit
  131. def scrypt(password: String, salt: BufferLike, keylen: Int, callback: Callback1[Buffer]): Unit
  132. def scrypt(password: String, salt: String, keylen: Int, callback: Callback1[Buffer]): Unit
  133. def scrypt(password: BufferLike, salt: BufferLike, keylen: Int, options: ScryptOptions, callback: Callback1[Buffer]): Unit
  134. def scrypt(password: BufferLike, salt: String, keylen: Int, options: ScryptOptions, callback: Callback1[Buffer]): Unit
  135. def scrypt(password: String, salt: BufferLike, keylen: Int, options: ScryptOptions, callback: Callback1[Buffer]): Unit
  136. def scrypt(password: String, salt: String, keylen: Int, options: ScryptOptions, callback: Callback1[Buffer]): Unit
  137. def scryptSync(password: BufferLike, salt: BufferLike, keylen: Int): Buffer
  138. def scryptSync(password: BufferLike, salt: String, keylen: Int): Buffer
  139. def scryptSync(password: String, salt: BufferLike, keylen: Int): Buffer
  140. def scryptSync(password: String, salt: String, keylen: Int): Buffer
  141. def scryptSync(password: BufferLike, salt: BufferLike, keylen: Int, options: ScryptOptions): Buffer
  142. def scryptSync(password: BufferLike, salt: String, keylen: Int, options: ScryptOptions): Buffer
  143. def scryptSync(password: String, salt: BufferLike, keylen: Int, options: ScryptOptions): Buffer
  144. def scryptSync(password: String, salt: String, keylen: Int, options: ScryptOptions): Buffer
  145. def secureHeapUsed(): HeapUsed
  146. def setEngine(engine: String): Unit
  147. def setEngine(engine: String, fips: Int): Unit
  148. def setFips(enable: Boolean): Unit
  149. def sign(data: BufferLike, key: KeyObject): Buffer
  150. def sign(data: BufferLike, key: Buffer): Buffer
  151. def sign(data: BufferLike, key: String): Buffer
  152. def sign(algorithm: String, data: BufferLike, key: KeyObject): Buffer
  153. def sign(algorithm: String, data: BufferLike, key: Buffer): Buffer
  154. def sign(algorithm: String, data: BufferLike, key: String): Buffer
  155. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  156. def timingSafeEqual(a: BufferLike, b: BufferLike): Boolean
  157. def toLocaleString(): String
    Definition Classes
    Object
  158. def toString(): String
    Definition Classes
    AnyRef → Any
  159. def valueOf(): Any
    Definition Classes
    Object
  160. def verify(data: BufferLike, key: KeyObject): Boolean
  161. def verify(data: BufferLike, key: Buffer): Boolean
  162. def verify(data: BufferLike, key: String): Boolean
  163. def verify(algorithm: String, data: BufferLike, key: KeyObject): Boolean
  164. def verify(algorithm: String, data: BufferLike, key: Buffer): Boolean
  165. def verify(algorithm: String, data: BufferLike, key: String): Boolean
  166. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  167. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  168. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. val DEFAULT_ENCODING: String

    The default encoding to use for functions that can take either strings or buffers.

    The default encoding to use for functions that can take either strings or buffers. The default value is 'buffer', which makes methods default to Buffer objects.

    The crypto.DEFAULT_ENCODING mechanism is provided for backwards compatibility with legacy programs that expect 'binary' to be the default encoding.

    Annotations
    @deprecated
    Deprecated

    (Since version Node.js v10.0) New applications should expect the default to be 'buffer'.

  2. def createCipher(algorithm: String, password: String): Cipher
    Annotations
    @deprecated
    Deprecated

    (Since version Node.js v10.0) Use crypto.createCipheriv() instead.

  3. def createCipher(algorithm: String, password: Buffer): Cipher

    Creates and returns a Cipher object that uses the given algorithm and password.

    Creates and returns a Cipher object that uses the given algorithm and password.

    algorithm

    The algorithm is dependent on OpenSSL, examples are 'aes192', etc. On recent OpenSSL releases, openssl list-cipher-algorithms will display the available cipher algorithms.

    password

    The password is used to derive the cipher key and initialization vector (IV). The value must be either a 'binary' encoded string or a Buffer.

    Annotations
    @deprecated
    Deprecated

    (Since version Node.js v10.0) Use crypto.createCipheriv() instead.

    Example:
    1. crypto.createCipher(algorithm, password)

  4. def createDecipher(algorithm: String, password: String): Decipher
    Annotations
    @deprecated
    Deprecated

    (Since version Node.js v10.0) Use crypto.createDecipheriv() instead.

  5. def createDecipher(algorithm: String, password: Buffer): Decipher

    Creates and returns a Decipher object that uses the given algorithm and password (key).

    Creates and returns a Decipher object that uses the given algorithm and password (key). The implementation of crypto.createDecipher() derives keys using the OpenSSL function EVP_BytesToKey with the digest algorithm set to MD5, one iteration, and no salt. The lack of salt allows dictionary attacks as the same password always creates the same key. The low iteration count and non-cryptographically secure hash algorithm allow passwords to be tested very rapidly.

    In line with OpenSSL's recommendation to use pbkdf2 instead of EVP_BytesToKey it is recommended that developers derive a key and IV on their own using crypto.pbkdf2() and to use crypto.createDecipheriv() to create the Decipher object.

    Annotations
    @deprecated
    Deprecated

    (Since version Node.js v10.0) Use crypto.createDecipheriv() instead.

    Example:
    1. crypto.createDecipher(algorithm, password)

  6. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated
  7. val fips: Boolean

    Property for checking and controlling whether a FIPS compliant crypto provider is currently in use.

    Property for checking and controlling whether a FIPS compliant crypto provider is currently in use. Setting to true requires a FIPS build of Node.js.

    Annotations
    @deprecated
    Deprecated

    (Since version Node.js v10.0) Please use crypto.setFips() and crypto.getFips() instead.

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped