question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

publicKey.encrypt is not a function

See original GitHub issue

I got this error privateKey.sign is not a function in the below code: var signature = crypt.signature(privateKey, text); Also publicKey.encrypt is not a function in here: var encrypted = crypt.encrypt(publicKey, text); Does anyone know about this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Zoey-rahimicommented, Sep 4, 2019

I found the issue! it was my mistake that inside the Crypt.js I had changed the name of sign method to signature !! I’m so sorry for taking your time for such a bad mistake!

I got this:

signature:  {"signature":"G4ifUHNBNYHKCVL3vz+4FMDSQ3hYC6nr7C8O1NFtq8zCgkPD2004gDhxBaGssQ/JXVeq2kC3L6zZLkoGfT9mPwnK4ojsXYUgLVm/H12K4iCwftpQn2csmkcVLaP0HJB0eYJOJLc+5Hhpty5CVdfOZgLpyNr4cgajML4+ekE3Sj8=","md":"sha1"}
C:\Users\ZoeyRahimi\ReactNative\Gamma_Demo\config\firebaseSDK.js:135 encrypted:  {"v":"hybrid-crypto-js_0.2.1","iv":"sc+A7PjYNNTLUwuSX3OyrB67I/ZSk31k+N4Dd/CvbXE=","keys":{"f4:db:70:89:6d:c7:3b:1d:f8:26:f9:b4:a4:64:9e:f2:3f:b2:58:6e":"JKWsm72EwIWd+OTEqN2ngj8LGJOQmchpd7g7ow7NkkoiBCwupVSIXuWAiiHCMqWUfszk5LUy/pMewEgWC0OFQB82glrDK+jjVP7nj7cHRsOo7FMaoRAXQARVnIB6KaN8d5SdWQj6AxydCgECZfkcSwGOy+o3oTrEHjJf5wF9nzw="},"cipher":"cOkyOVyffrA9yxBKFLpCnw==","signature":"{\"signature\":\"G4ifUHNBNYHKCVL3vz+4FMDSQ3hYC6nr7C8O1NFtq8zCgkPD2004gDhxBaGssQ/JXVeq2kC3L6zZLkoGfT9mPwnK4ojsXYUgLVm/H12K4iCwftpQn2csmkcVLaP0HJB0eYJOJLc+5Hhpty5CVdfOZgLpyNr4cgajML4+ekE3Sj8=\",\"md\":\"sha1\"}"}
C:\Users\ZoeyRahimi\ReactNative\Gamma_Demo\config\firebaseSDK.js:137 decrypted:  {message: "Hello world", signature: "{"signature":"G4ifUHNBNYHKCVL3vz+4FMDSQ3hYC6nr7C8O…Hhpty5CVdfOZgLpyNr4cgajML4+ekE3Sj8=","md":"sha1"}"}
C:\Users\ZoeyRahimi\ReactNative\Gamma_Demo\config\firebaseSDK.js:143 verify:  true
0reactions
juhoencommented, Sep 4, 2019

It seems that, for a some reason, private key gets never casted into forge private key object. What’s your output for console.log(typeof keys.privateKey) ? It would be nice to know what value privateKey has just before the line that causes the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nodejs `crypto.publicEncrypt` would not take public key ...
The generated public key looks like this: ssh-rsa AAAAB3NzaC1yc2EAAA... When I try to use crypto in Node.js to encrypt a plain string,
Read more >
Crypto | Node.js v19.3.0 Documentation
PKCS#1 and SEC1 can only be encrypted by specifying a cipher when the PEM format is used. For maximum compatibility, use PKCS#8 for...
Read more >
crypto/rsa - Go Packages
Package rsa implements RSA encryption as specified in PKCS #1 and RFC 8017. ... to this function – the random data need not...
Read more >
Public key encryption (article) - Khan Academy
It's a "one-way function ", which means it's incredibly difficult for a computer to reverse the operation and discover the original data. Even...
Read more >
SubtleCrypto.encrypt() - Web APIs | MDN
However, it need not be secret (for example, it may be transmitted ... The RSA-OAEP public-key encryption system is specified in RFC 3447....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found