前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Rust日报】Diesel 发布新版本 2.2.0

【Rust日报】Diesel 发布新版本 2.2.0

作者头像
MikeLoveRust
发布2024-06-07 20:58:21
1010
发布2024-06-07 20:58:21
举报

Diesel 发布新版本 2.2.0

Diesel 是一个安全且高性能的查询构建器和用 Rust 编写的 ORM。此版本包含多项新功能并改进了现有功能。Diesel 现在提供了一个过程宏属性,用于推断查询的正确返回类型。现在可以检测Diesel提供的连接实现,以执行记录和性能测量。我们添加了对 PostgreSQL COPY FROMCOPY TO 语法的支持,可用于有效地发送和接收大量数据。我们的依赖项包装了本机数据库驱动程序,现在支持所有构建数据库驱动程序作为 . cargo build 这使我们能够轻松地分发 diesel-cli 的静态预编译版本。最后,我们与 Rust 团队合作,稳定属性,以自定义编译器发出的错误消息。现在,Diesel使用它来提高某些难以理解的错误消息的质量。

更多信息查看 GitHub,https://github.com/diesel-rs/diesel

rencrypt-python 在 Rust 中实现的 Python 加密库。

它支持带有 AES-GCM 和 ChaCha20Poly1305 的 AEAD。它使用ring crate来处理加密。

使用内存中的缓冲区进行加密和解密 这是使用它的最高性能方式,因为它不会将字节复制到缓冲区,也不会为明文和密文分配新内存。

代码语言:javascript
复制
from rencrypt import REncrypt, Cipher
import os
from zeroize import zeroize1


# You can use also other ciphers like `cipher = Cipher.ChaCha20Poly1305`.
cipher = Cipher.AES256GCM
key = cipher.generate_key()
# The key is copied and the input key is zeroized for security reasons.
# The copied key will also be zeroized when the object is dropped.
enc = REncrypt(cipher, key)

# we get a buffer based on block len 4096 plaintext
# the actual buffer will be 28 bytes larger as in ciphertext we also include the tag and nonce
plaintext_len, ciphertext_len, buf = enc.create_buf(4096)
aad = b"AAD"

# put some plaintext in the buffer, it would be ideal if you can directly collect the data into the buffer without allocating new memory
# but for the sake of example we will allocate and copy the data
plaintext = bytearray(os.urandom(plaintext_len))
# enc.copy_slice is slighlty faster than buf[:plaintext_len] = plaintext, especially for large plaintext, because it copies the data in parallel
# enc.copy_slice takes bytes as input, enc.copy_slice1 takes bytearray
enc.copy_slice1(plaintext, buf)
# encrypt it, this will encrypt in-place the data in the buffer
print("encryping...")
ciphertext_len = enc.encrypt(buf, plaintext_len, 42, aad)
cipertext = buf[:ciphertext_len]
# you can do something with the ciphertext

# decrypt it
# if you need to copy ciphertext to buffer, we don't need to do it now as it's already in the buffer
# enc.copy_slice(ciphertext, buf[:len(ciphertext)])
print("decryping...")
plaintext_len = enc.decrypt(buf, ciphertext_len, 42, aad)
plaintext2 = buf[:plaintext_len]
assert plaintext == plaintext2

# best practice, you should always zeroize the plaintext and keys after you are done with it (key will be zeroized when the enc object is dropped)
zeroize1(plaintext)
zeroize1(plaintext2)

print("bye!")

更多信息请查看github, https://github.com/radumarias/rencrypt-python

GPM 一个完全可定制的通用包管理器

你想制作自己的包管理器吗?

初始化包管理器

代码语言:javascript
复制
gpm init

添加新的包类型

代码语言:javascript
复制
gpm type add <NAME> <EXT> <SHELL>

Change your shell config at ~/.gpm/types.toml. 在 ~/.gpm/types.toml 中更改 shell 配置。

更多信息查看 GitHub,https://github.com/8LWXpg/gpm

From 日报小组 [倪步烤Neo]

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-06-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Rust语言学习交流 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Diesel 发布新版本 2.2.0
  • rencrypt-python 在 Rust 中实现的 Python 加密库。
  • GPM 一个完全可定制的通用包管理器
    • 初始化包管理器
      • 添加新的包类型
      相关产品与服务
      数据库
      云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档