Generate a public / private Key RSA with Apps Scri

2019-08-20 09:41发布

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 ..

1条回答
男人必须洒脱
2楼-- · 2019-08-20 09:48

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.

查看更多
登录 后发表回答