1

i would like to create a public/private key RSA with the Apps Script service of Google. I found documentation but it's not seen to have someting like "generate key" or like in c# using the RSACryptoServiceProvider when you can create a key and export it to XML.

I take a look on this documentation https://developers.google.com/apps-script/reference/utilities/

var signature = Utilities.computeRsaSha256Signature("this is my input",
    "-----BEGIN PRIVATE KEY-----\nprivatekeyhere\n-----END PRIVATE KEY-----\n");

How can i generate my "KEY" what is the right method to do it ?

To clarify my request, in c# we can do it like that.

using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(keySize))
      {
        privateKey = RSA.ToXmlString(true);
      }

That will generate a private key runtime, i try to do the same with Apps Script, is it possible ?

edited part

In fact i already have a javascript class with whoe i can generate RSA key but it's take to much time run it in .Gs code file. My Javascript code work well in a browser, but when it run into a .gs file ... it's seen to be very more slowly

I am looking for a "Native" service from Google to do it ..

Cédric Boivin
  • 10,854
  • 13
  • 57
  • 98

1 Answers1

6

You don't generate RSA public/private keys with Google Apps Scripts. You use apps scripts with the RSA keys you generated elsewhere. There are many way to generate them.

One of them is using openssl.

In this link you have the instructions to generate them using openssl:

https://developers.yubico.com/PIV/Guides/Generating_keys_using_OpenSSL.html

@edit I found at least 4 questions in SO that show how to do this using javascript:

Generate RSA keys using javascript?

How to generate rsa key pair in client side using angular2?

Generate RSA key pair in javascript, based on a password

Generate well-formed SSH key in JavaScript

please always search a bit before asking.

Nelson Teixeira
  • 6,297
  • 5
  • 36
  • 73
  • Yes but if i need to generat it runtime! How can i do it? You told me that we are not able to generate RSA key at the runtime. – Cédric Boivin Aug 23 '18 at 16:02
  • 1
    thank but in fact i already have algorithme to generate RSA key in Jasvascript. My problem is i am not able to generate a 512 bits keysize in my .gs code, it's take to much time. In javascript, in a browswer, there is no problem to do it. I was looking for Google Services that was enable to generate my key instead using native javascript. – Cédric Boivin Aug 23 '18 at 16:27
  • but your links could be usefull for people whoe looking for native javascript – Cédric Boivin Aug 23 '18 at 16:29
  • 1
    AFAIK there isn't a Google Service for that. Even Google Support advises you generate with openssl. Look: https://support.google.com/a/answer/6342198?hl=en – Nelson Teixeira Aug 23 '18 at 16:33
  • 1
    Teixeira, thank for your help. "Merci pour ton aide" ;-) – Cédric Boivin Aug 23 '18 at 16:38