本文介绍了使用Apps脚本生成公共/私有密钥RSA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Google的Apps Script服务创建一个公共/私有密钥RSA.我找到了文档,但是当您可以创建密钥并将其导出到XML时,它并没有像生成密钥"之类的东西或使用 RSACryptoServiceProvider 在c#中那样.

我查看了此文档 https://developers.google.com/apps-script/reference/utilities/

  var签名= Utilities.computeRsaSha256Signature(这是我的输入","----- BEGIN PRIVATE KEY ----- \ nprivatekeyhere \ n ----- END PRIVATE KEY ----- \ n"); 

我如何生成密钥",正确的方法是什么?

为澄清我的要求,在c#中我们可以这样做.

 使用(RSACryptoServiceProvider RSA =新的RSACryptoServiceProvider(keySize)){privateKey = RSA.ToXmlString(true);} 

这将生成一个私钥运行时,我尝试对Apps Script进行同样的操作吗?

编辑部分

事实上,我已经有了一个可以生成RSA密钥的javascript类,但是在.Gs代码文件中运行它需要花费大量时间.我的Javascript代码在浏览器中可以很好地运行,但是当它运行到.gs文件中时……看起来会非常慢

我正在寻找Google提供的本地"服务..

解决方案

您不会使用Google Apps脚本生成RSA公钥/私钥.您可以将应用程序脚本与在其他位置生成的RSA密钥一起使用.生成它们的方法有很多.

其中之一正在使用openssl.

在此链接中,您具有使用openssl生成它们的说明:

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

@edit我在SO中至少发现了4个问题,这些问题说明了如何使用javascript做到这一点:

使用javascript生成RSA密钥?

如何在客户端使用angular2吗?

基于JavaScript生成RSA密钥对密码

在JavaScript中生成格式正确的SSH密钥

在询问之前,请务必进行一些搜索.

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

解决方案

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.

这篇关于使用Apps脚本生成公共/私有密钥RSA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 07:45