Class KJUR.crypto.Cipher
Cipher class to encrypt and decrypt data
Defined in: crypto-1.1.js.
Constructor Attributes | Constructor Name and Description |
---|---|
KJUR.crypto.Cipher(params)
Cipher class to encrypt and decrypt data
Here is supported canonicalized cipher algorithm names and its standard names:
|
Method Attributes | Method Name and Description |
---|---|
<static> |
KJUR.crypto.Cipher.decrypt(hex, keyObj, algName, param)
decrypt encrypted hexadecimal string with specified key and algorithm
This static method decrypts encrypted hexadecimal string with specified key and algorithm. |
<static> |
KJUR.crypto.Cipher.encrypt(s, keyObj, algName, param)
encrypt raw string by specified key and algorithm
This static method encrypts raw string with specified key and algorithm. |
<static> |
KJUR.crypto.Cipher.getAlgByKeyAndName(keyObj, algName)
get canonicalized encrypt/decrypt algorithm name by key and short/long algorithm name
Here is supported canonicalized cipher algorithm names and its standard names:
|
Class Detail
KJUR.crypto.Cipher(params)
Cipher class to encrypt and decrypt data
Here is supported canonicalized cipher algorithm names and its standard names:
Currently this class supports only RSA encryption and decryption based on RSAES-OAEP and RSAES-PKCS1-v1_5 scheme. However it is planning to implement also symmetric ciphers near in the future
Here is supported canonicalized cipher algorithm names and its standard names:
- RSA - RSA/ECB/PKCS1Padding (default for RSAKey)
- RSAOAEP - RSA/ECB/OAEPWithSHA-1AndMGF1Padding
- RSAOAEP224 - RSA/ECB/OAEPWithSHA-224AndMGF1Padding(*)
- RSAOAEP256 - RSA/ECB/OAEPWithSHA-256AndMGF1Padding
- RSAOAEP384 - RSA/ECB/OAEPWithSHA-384AndMGF1Padding(*)
- RSAOAEP512 - RSA/ECB/OAEPWithSHA-512AndMGF1Padding(*)
Currently this class supports only RSA encryption and decryption based on RSAES-OAEP and RSAES-PKCS1-v1_5 scheme. However it is planning to implement also symmetric ciphers near in the future
- Parameters:
- {Array} params
- parameters for constructor
- Since:
- jsrsasign 6.2.0 crypto 1.1.10
Method Detail
<static>
{String}
KJUR.crypto.Cipher.decrypt(hex, keyObj, algName, param)
decrypt encrypted hexadecimal string with specified key and algorithm
This static method decrypts encrypted hexadecimal string with specified key and algorithm.
NOTE: From jsrsasign 10.9.0, asymmetric cipher ({des-EDE3,aes{128,256}}-CBCis also supported.
This static method decrypts encrypted hexadecimal string with specified key and algorithm.
NOTE: From jsrsasign 10.9.0, asymmetric cipher ({des-EDE3,aes{128,256}}-CBCis also supported.
// asynchronous cipher KJUR.crypto.Cipher.decrypt("aaa", prvRSAKeyObj) → "1abc2d..." KJUR.crypto.Cipher.decrypt("aaa", prvRSAKeyObj, "RSAOAEP) → "23ab02..." // synchronous cipher KJUR.crypto.Cipher.decrypt("12abcd...", "5a7d...", "aes256-CBC", { iv: "1b3c..." }) KJUR.crypto.Cipher.decrypt("12abcd...", "5a7d...", any, { encalg: "aes128-CBC", iv: "1b3c..." }) KJUR.crypto.Cipher.decrypt("12abcd...", any, any, { encalg: "des-EDE3-CBC", iv: "1b3c...", key: "3d41..." }) KJUR.crypto.Cipher.decrypt(any, any, any, { encalg: "des-EDE3-CBC", iv: "1b3c...", key: "3d41...", enc: "12abcd..." })
- Parameters:
- {string} hex
- hexadecimal string of encrypted message
- {object} keyObj
- RSAKey object or hexadecimal string of symmetric cipher key
- {string} algName
- short/long algorithm name for encryption/decryption (OPTION)
- {object} param
- parameters for synchronous cipher such as initial vector (OPTION)
- Since:
- jsrsasign 6.2.0 crypto 1.1.10
- Returns:
- {String} decrypted raw string
<static>
{String}
KJUR.crypto.Cipher.encrypt(s, keyObj, algName, param)
encrypt raw string by specified key and algorithm
This static method encrypts raw string with specified key and algorithm.
NOTE: From jsrsasign 10.9.0, asymmetric cipher ({des-EDE3,aes{128,256}}-CBC) is also supported.
This static method encrypts raw string with specified key and algorithm.
NOTE: From jsrsasign 10.9.0, asymmetric cipher ({des-EDE3,aes{128,256}}-CBC) is also supported.
// asynchronous cipher KJUR.crypto.Cipher.encrypt("aaa", pubRSAKeyObj) → "1abc2d..." KJUR.crypto.Cipher.encrypt("aaa", pubRSAKeyObj, "RSAOAEP") → "23ab02..." // synchronous cipher KJUR.crypto.Cipher.encrypt("12abcd...", "5a7d...", "aes256-CBC", { iv: "1b3c..." }) KJUR.crypto.Cipher.encrypt("12abcd...", "5a7d...", any, { encalg: "aes128-CBC", iv: "1b3c..." }) KJUR.crypto.Cipher.encrypt("12abcd...", any, any, { encalg: "des-EDE3-CBC", iv: "1b3c...", key: "3d41..." }) KJUR.crypto.Cipher.encrypt(any, any, any, { encalg: "des-EDE3-CBC", iv: "1b3c...", key: "3d41...", enc: "12abcd..." })
- Parameters:
- {String} s
- input string to encrypt
- {Object} keyObj
- RSAKey object or hexadecimal string of symmetric cipher key
- {String} algName
- short/long algorithm name for encryption/decryption (OPTION)
- {object} param
- parameters for synchronous cipher such as initial vector (OPTION)
- Since:
- jsrsasign 6.2.0 crypto 1.1.10
- Returns:
- {String} hexadecimal encrypted string
<static>
{String}
KJUR.crypto.Cipher.getAlgByKeyAndName(keyObj, algName)
get canonicalized encrypt/decrypt algorithm name by key and short/long algorithm name
Here is supported canonicalized cipher algorithm names and its standard names:
Here is supported canonicalized cipher algorithm names and its standard names:
- RSA - RSA/ECB/PKCS1Padding (default for RSAKey)
- RSAOAEP - RSA/ECB/OAEPWithSHA-1AndMGF1Padding
- RSAOAEP224 - RSA/ECB/OAEPWithSHA-224AndMGF1Padding(*)
- RSAOAEP256 - RSA/ECB/OAEPWithSHA-256AndMGF1Padding
- RSAOAEP384 - RSA/ECB/OAEPWithSHA-384AndMGF1Padding(*)
- RSAOAEP512 - RSA/ECB/OAEPWithSHA-512AndMGF1Padding(*)
KJUR.crypto.Cipher.getAlgByKeyAndName(objRSAKey) → "RSA" KJUR.crypto.Cipher.getAlgByKeyAndName(objRSAKey, "RSAOAEP") → "RSAOAEP"
- Parameters:
- {Object} keyObj
- RSAKey object or hexadecimal string of symmetric cipher key
- {String} algName
- short/long algorithm name for encryption/decryption
- Since:
- jsrsasign 6.2.0 crypto 1.1.10
- Returns:
- {String} canonicalized algorithm name for encryption/decryption