import WxmpRsa from 'wxmp-rsa'

const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCh6HkK+rCM37FAzCHVythTc6pxvr551K07CRhdX/NjCddHAuQMOd/57R5fiIwgVNEfCsD1cIyS6A8IWj4DtJLR2t29JehPpqiFSJ4hNtDcLNxNJiYRcCQvyMQeyQIPE5Ljc35c72YwDtQAsIJChsauyLrc+E6HC3gn1JDm18HNXwIDAQAB'

export function rsaEncrypt(text: string) {
  const encryptor = new WxmpRsa()
  encryptor.setPublicKey(publicKey)
  const encrypted = encryptor.encrypt(text)
  if (encrypted === false) {
    throw new Error('Password encryption failed')
  }
  return encrypted
}

