如何保护我的文件不发送到Skype或上载到cPanel

如何解决如何保护我的文件不发送到Skype或上载到cPanel

我正在为公司中的应用程序编程,并且有一个文件监视程序:

fsw.NotifyFilter = (NotifyFilters.Security Or NotifyFilters.LastAccess Or NotifyFilters.LastWrite)

AddHandler fsw.Changed,New FileSystemEventHandler(AddressOf OnChanged) 

AddHandler fsw.Created,AddressOf OnChanged

AddHandler fsw.Renamed,AddressOf OnRenamed

AddHandler fsw.Deleted,AddressOf OnChanged

但是我想通过在Skype中发送文件,将文件上传或上传到任何云来保护某些文件免受用户侵害。

例如我有一个可以使用dogland.exe打开的dgg文件,我想将此.dgg扩展名仅与此应用一起使用,并对其进行加密和保护,以防其他程序读取此文件。

保护此文件的最佳方法是什么? 我正在使用vb.net 4.6.1

解决方法

如果您愿意的话,您将无法阻止在其计算机上具有管理员权限的用户发送文件,所以您的答案是使它在其他地方毫无用处。

在回答您的问题之前,我想解决两个关键点:

  1. 安全性分为不同级别。在信息安全方面,您所获得的保护级别与您投入的工作量有关;
  2. 您不能阻止熟练的,坚定的攻击者,因为某处总是存在弱点。您所能做的就是使他们的工作更加艰辛。您必须确定您愿意承担的风险状况以及需要做出的努力。

也就是说,最简单的绝对方法是对称加密,其中程序使用相同的密钥进行加密和解密。有人检查您的代码并获取密钥很容易受到攻击,但是它将阻止大多数偶然的尝试。

要尝试,请以主要形式输入:

    Private Function Encrypt3DES(plainText As String,pw As String) As String
        Dim wrapper As New Simple3Des(pw)
        Dim cipherText As String = wrapper.EncryptData(plainText)
        Return cipherText
    End Function

    Private Function Decrypt3DES(cipherText As String,pw As String,ByRef plainText As String) As Boolean
        Dim wrapper As New Simple3Des(pw)
        ' DecryptData throws if the wrong password is used.
        Try
            plainText = wrapper.DecryptData(cipherText)
            Return True
        Catch ex As System.Security.Cryptography.CryptographicException
            Return False
        End Try
    End Function

这进入了一个帮助器模块:

Imports System.Security.Cryptography
Public NotInheritable Class Simple3Des
    Private TripleDes As New TripleDESCryptoServiceProvider
    Sub New(ByVal key As String)
        ' Initialize the crypto provider.
        TripleDes.Key = TruncateHash(key,TripleDes.KeySize \ 8)
        TripleDes.IV = TruncateHash("",TripleDes.BlockSize \ 8)
    End Sub
    Private Function TruncateHash(
    ByVal key As String,ByVal length As Integer) As Byte()

        Dim sha1 As New SHA1CryptoServiceProvider

        ' Hash the key.
        Dim keyBytes() As Byte =
            System.Text.Encoding.Unicode.GetBytes(key)
        Dim hash() As Byte = sha1.ComputeHash(keyBytes)

        ' Truncate or pad the hash.
        ReDim Preserve hash(length - 1)
        Return hash
    End Function
    Public Function EncryptData(
    ByVal plaintext As String) As String

        ' Convert the plaintext string to a byte array.
        Dim plaintextBytes() As Byte =
            System.Text.Encoding.Unicode.GetBytes(plaintext)

        ' Create the stream.
        Dim ms As New System.IO.MemoryStream
        ' Create the encoder to write to the stream.
        Dim encStream As New CryptoStream(ms,TripleDes.CreateEncryptor(),System.Security.Cryptography.CryptoStreamMode.Write)

        ' Use the crypto stream to write the byte array to the stream.
        encStream.Write(plaintextBytes,plaintextBytes.Length)
        encStream.FlushFinalBlock()

        ' Convert the encrypted stream to a printable string.
        Return Convert.ToBase64String(ms.ToArray)
    End Function
    Public Function DecryptData(
    ByVal encryptedtext As String) As String
        Try
            ' Convert the encrypted text string to a byte array.
            Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext)

        ' Create the stream.
        Dim ms As New System.IO.MemoryStream
        ' Create the decoder to write to the stream.
        Dim decStream As New CryptoStream(ms,TripleDes.CreateDecryptor(),System.Security.Cryptography.CryptoStreamMode.Write)

        ' Use the crypto stream to write the byte array to the stream.
        decStream.Write(encryptedBytes,encryptedBytes.Length)
        decStream.FlushFinalBlock()

            ' Convert the plaintext stream to a string.
            Return System.Text.Encoding.Unicode.GetString(ms.ToArray)

        Catch ex As Exception
            Return ""
        End Try
    End Function
End Class

要实现上述代码,只需在对数据进行调用之前将其加密方法写入文件:

Dim encdata = Encrypt3DES(PlainTextStringToEncrypt,password)
' Write encdata to file...

从文件加载数据后,您调用Decrypt3DES解密数据:

Dim DecodedData as string = ""
If Decrypt3DES(EncryptedData,Password,DecodedData) = True Then
    'Do something with DecodedData
End If

这可能是最简单的解决方案,但是“最佳”一词在信息安全中是相对的。您需要根据要保护的信息的价值和暴露信息的风险状况来调整工作水平。您可以做太多或做得太少。

通过不将加密密钥存储在本地,而是在运行时从服务器检索加密密钥,并在使用后立即从内存中清除它,可以使此方法更强大。或者,您可以对加密密码进行加密,因此实际的密码本身在反汇编程序中不可见,因此需要进行额外的工作。您可以做一千件事-希望这可以为您提供一个起点。

如果您想获得更高级的知识,可以研究用户无权访问的基于证书的签名和/或基于服务器的控件。所有这些都是值得保护的信息的问题。

免责声明:我不保证此设置适用于任何特定目的。这可能适合或不适合您的需求。做您自己的研究,并确保所有安全机制都适合您的目的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res