Hello Everyone, I want to verify a signature usin...
# suitescript
y
Hello Everyone, I want to verify a signature using the N/pgp module, I am trying to use below api, but always returns an empty
Copy code
pgp.createVerification()
I have created a signature using pgp.createSigner(). Below is the code for your reference. Anyone have an idea how to verify a signature?
Copy code
/**
 * @NApiVersion 2.1
 */

require(['N/pgp', 'N/crypto/certificate', 'N/encode'], (pgp, cryptoCertificate, encode) => {
  const keys = {
    ours: {
      pub: pgp.loadKeyFromSecret({
        secret: { scriptId: 'custsecret_pgp_key_ours_public' }
      }),
      pri: pgp.loadKeyFromSecret({
        secret: { scriptId: 'custsecret_pgp_key_ours_private' },
        password: { scriptId: 'custsecret_pgp_key_ours_private_password' }
      })
    }
  }
  const signer = pgp.createSigner({
    key: keys.ours.pri,
    algorithm: cryptoCertificate.HashAlg.SHA256
  })
  signer.update({
    input: 'Test'
  })
  const signature = signer.sign({
    outputEncoding: encode.Encoding.BASE_64_URL_SAFE
  })

  log.debug(signature)
})