如何在R中加密数据

如何在R中加密数据

本文介绍了如何在R中加密数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在添加哨兵处理程序 R日志记录包.当前 django-sentry 基于行进的共享密钥验证客户端(发送日志记录的应用程序)在安全通道中以明文形式显示.

I am adding a sentry handler to the R logging package. currently django-sentry validates the client (the application sending log records) based on a shared key which travels in clear text in a secured channel.

我想知道是否可以从R(最好是非对称的,基于公钥)进行加密,但是我发现没有任何意义.

I was wondering if it was possible to do encryption from R, preferably asymmetric, public key based, but I find nothing relevant.

好吧,不是如果可能",而是如何做到"以及是否有人已经这样做.

all right, not "if it was possible", but "how to do that" and whether someone already did this.

在与django-sentry的作者进行互动之后,我们选择了hmac,我已经在 digest R程序包(版本0.5+包含它).这不是不是回答如何使用R加密数据"的问题,但是它解决了构成我最初问题基础的问题.

after interaction with the author of django-sentry, we opted for hmac, which I have implemented within the digest R package (version 0.5+ contains it). This does not answer the question "how to encrypt data using R", but it solves the problem which formed the base for my initial question.

在这一点上,我不再积极从事R中的非对称刻写工作,但是,如果您对此感兴趣,并且想贡献点子或编写代码,请在此处留下注释!

At this point I am not any more actively working at asymmetric encription in R, however, if you are interested in it and you want to contribute ideas or code, please leave a note here!

推荐答案

您还可以在 PKI包,来自作者Simon Urbanek.

You may also find suitable function in the PKI package from the author Simon Urbanek.

此软件包提供了PKI功能,例如verifyig证书,RSA加密和签名,可用于构建PKI基础结构并执行加密任务.

This package provides PKI functions such as verifyig certificates, RSA encription and signing which can be used to build PKI infrastructure and perform cryptographic tasks.

教程中的示例代码:

require(PKI)
key <- PKI.genRSAkey(2048)
x <- charToRaw("Hello, world!")
e <- PKI.encrypt(x, key)
y <- PKI.decrypt(e, key)
stopifnot(identical(x, y))
print(rawToChar(y))

给出结果:[1] "Hello, world!"

而加密消息e是:

  [1] 36 83 d3 70 0a 67 b5 05 a6 40 1e 37 28 b9 4e 28 f1 31 92 14 2c 35 c8 8a 61 93 1e 04 62 01 da 3b 2b a0 75 1c 10 58 26
 [40] e4 77 da 7a 47 3f 4e 44 29 8e 97 6f 62 b1 98 44 ba 18 ef 57 1e 9e 9c 27 a8 6e 9c 7b c7 8b c0 c3 a3 00 e2 67 98 8b 6e
 [79] 1a 93 c6 d6 ed 4b 54 e5 7a 07 d7 06 ef a6 bb 36 6a 7f 57 06 b9 15 03 f6 51 3f 07 48 cb f4 2d 25 15 be 42 de f4 8a 06
[118] 72 89 b1 e3 04 d3 ec 80 99 f0 66 0f 84 e1 b5 af 23 24 a1 36 8e 62 65 ae 19 fb 77 d1 36 06 ae 71 95 ee 57 aa 68 5a 6b
[157] 4e 28 ba a2 0d 17 78 11 6c 7f 1b b3 ce 31 65 a9 d3 71 89 76 f9 19 a0 7a bf 02 dd c9 1f cb 9c 39 25 d4 48 a2 23 83 26
[196] b4 a9 b1 40 f5 1d 46 21 35 12 52 73 09 9b f3 52 e1 9e 0d 2a 9b ff 70 81 41 24 49 ed 58 b2 61 dc 3e c9 b3 b2 b1 37 e0
[235] 48 76 18 bf b0 e5 c2 d9 2b 92 2f 6b 49 dd e0 93 b7 10 f8 ba d2 8a

这篇关于如何在R中加密数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:05