golang 加密文件_如何使用Go加密文件

本文是关于使用Go语言进行文件加密的简短指南,介绍如何利用Go实现文件的安全加密,保护数据隐私。
摘要由CSDN通过智能技术生成

golang 加密文件

Cryptography is mandatory in the current modern world. In this era of big data and data science, it is important to make sure your data is protected from a malicious attack.

在当前现代世界中,密码术是必不可少的。 在当今大数据和数据科学时代,确保保护您的数据免受恶意攻击非常重要。

There are many algorithms and techniques to ensure that your system is secure and no unauthorized access will be done to your data.

有许多算法和技术可以确保您的系统安全,并且不会对数据进行未经授权的访问。

Symmetric encryption is one of these techniques, and in this tutorial, I will show you how to do it in Go.

对称加密是这些技术之一,在本教程中,我将向您展示如何在Go中进行加密。

Note: The version of Go used in this tutorial is 1.14.7.

注意:本教程中使用的Go版本是1.14.7。

介绍 (Introduction)

The symmetric-key encryption is a technique used to encrypt a message where there is only one secret key. This key is used on both parts of the process, that is, to encrypt and decrypt the message.

对称密钥加密是一种用于加密只有一个秘密密钥的消息的技术。 该密钥在过程的两个部分都使用,即加密和解密消息。

Image for post
Image by author.
图片由作者提供。

Using any kind of symmetric-key algorithm, a message is converted into a form that cannot be understood. Unless someone has the secret key. In this case, both the sender and the receiver have the same key (exchanged in some secure way) so they can send messages and understand each other.

使用任何一种对称密钥算法,都会将消息转换为无法理解的形式。 除非有人拥有密钥。 在这种情况下,发送方和接收方都具有相同的密钥(以某种安全方式进行了交换),因此它们可以发送消息并相互理解。

The algorithm used determines the size of the key and the mode that the process of encryption or decryption is done. And, usually, longer the key, harder is to hack it and more secure is your encryption. For example, a 128-bits key can take up to billions of years to be broken by a normal computer.

所使用的算法确定密钥的大小以及完成加密或解密过程的方式。 而且,通常,密钥越长,破解就越困难,而加密则更加安全。 例如,一个128位的密钥可能需要数十亿年才能被普通计算机破解。

There are two types of algorithms:

有两种算法:

  • Block: the message is encrypted using fixed-size blocks. Example: DES, AES, etc.

    :使用固定大小的块对消息进行加密。 例如: DESAES等。

  • Stream: the message is encrypted taking individual characters. Example: RC4,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
gocryptfs 是一个使用 Go 开发的,加密的覆盖文件系统。gocryptfs 基于 go-fuse FUSE 库和其 LoopbackFileSystem API 构建。gocryptfs 灵感来源于 EncFS,修复了其安全问题,提供更好的性能。gocryptfs 当前只支持 Linux 系统,以后会继续支持 OS X。安装:$ go get github.com/rfjakob/gocryptfs使用:$ mkdir cipher plain $ $GOPATH/bin/gocryptfs --init cipher   [...] $ $GOPATH/bin/gocryptfs cipher plain   [...] $ echo test > plain/test.txt $ ls -l cipher   total 8   -rw-rw-r--. 1 user  user   33  7. Okt 23:23 0ao8Hyyf1A-A88sfNvkUxA==   -rw-rw-r--. 1 user  user  233  7. Okt 23:23 gocryptfs.conf $ fusermount -u plain性能:./benchmark.bash gocryptfs v0.3.1-30-gd69e0df-dirty; on-disk format 2 PASS BenchmarkStreamWrite-2       100      12246070 ns/op      85.63 MB/s BenchmarkStreamRead-2        200       9125990 ns/op     114.90 MB/s BenchmarkCreate0B-2        10000        101284 ns/op BenchmarkCreate1B-2        10000        178356 ns/op       0.01 MB/s BenchmarkCreate100B-2       5000        361014 ns/op       0.28 MB/s BenchmarkCreate4kB-2        5000        375035 ns/op      10.92 MB/s BenchmarkCreate10kB-2       3000        491071 ns/op      20.85 MB/s ok      github.com/rfjakob/gocryptfs/integration_tests  17.216s 标签:文件加密
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值