powered by simpleCommunicator - 2.0.53     © 2025 Programmizd 02
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / pgp -шифрование
3 сообщений из 3, страница 1 из 1
pgp -шифрование
    #39212310
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Добрый день! Есть ли какие-либо реализации pgp шифрования файлов через vb или Cи имея на руках публичный ключ?
По результатам поиска нашел платный продукт от Didisoft и стандартный класс RSA, но он к сожалению шифрует не в pgp. Спасибо
...
Рейтинг: 0 / 0
pgp -шифрование
    #39213624
Фотография ЕвгенийВ
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
pgp -шифрование
    #39218866
vb_sub
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
ЕвгенийВ,
спасибо огромное!!! С помощью этой статьи и сайта http://www.carlosag.net/tools/codetranslator/
написал на VB.net.
Если кому- то понадобится код:
Код: vbnet
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
Imports Starksoft.Cryptography.OpenPGP
Imports System.IO
Imports ClassLibrary1.cls

Module my_int
    'Imports System.Text
    Public Class EncryptionService
        Implements IEncryptionService

        Private gpg As GnuPG = New GnuPG

        Private appPath As String
#Region "Constructors"
        Public Sub New()
            MyBase.New

        End Sub
        Public Sub New(ByVal appPath As String)
            MyBase.New
            Me.appPath = Me.appPath
        End Sub
#End Region

        Public Function DecryptFile(ByVal encryptedSourceFile As String, ByVal decryptedFile As String) As FileInfo
            ' check parameters
            If String.IsNullOrEmpty(encryptedSourceFile) Then
                Throw New ArgumentException("encryptedSourceFile parameter is either empty or null", "encryptedSourceFile")
            End If

            If String.IsNullOrEmpty(decryptedFile) Then
                Throw New ArgumentException("decryptedFile parameter is either empty or null", "decryptedFile")
            End If

            Dim encryptedSourceFileStream As FileStream = New FileStream(encryptedSourceFile, FileMode.Open)
            '  make sure the stream is at the start.
            encryptedSourceFileStream.Position = 0
            Dim decryptedFileStream As FileStream = New FileStream(decryptedFile, FileMode.Create)
            '  Specify the directory containing gpg.exe (again, not sure why).
            Me.gpg.BinaryPath = Path.GetDirectoryName(Me.appPath)
            '  Decrypt
            Me.gpg.Decrypt(encryptedSourceFileStream, decryptedFileStream)
            Return New FileInfo(decryptedFile)
        End Function

        Public Function EncryptFile(ByVal keyUserId As String, ByVal sourceFile As String, ByVal encryptedFile As String) As FileInfo
            ' check parameters

            If String.IsNullOrEmpty(keyUserId) Then
                Throw New ArgumentException("keyUserId parameter is either empty or null", "keyUserId")
            End If

            If String.IsNullOrEmpty(sourceFile) Then
                Throw New ArgumentException("sourceFile parameter is either empty or null", "sourceFile")
            End If

            If String.IsNullOrEmpty(encryptedFile) Then
                Throw New ArgumentException("encryptedFile parameter is either empty or null", "encryptedFile")
            End If

            Dim sourceFileStream As Stream = New FileStream(sourceFile, FileMode.Open)
            Dim encryptedFileStream As Stream = New FileStream(encryptedFile, FileMode.Create)
            '  Specify the directory containing gpg.exe (not sure why).
            ' Me.gpg.BinaryPath = Path.GetDirectoryName(Me.appPath)

            Me.gpg.BinaryPath = Path.GetDirectoryName("C:\Program Files\GNU\GnuPG\pub\")

            Me.gpg.Recipient = keyUserId
            '  Perform encryption
            Me.gpg.Encrypt(sourceFileStream, encryptedFileStream)
            Return New FileInfo(encryptedFile)
        End Function

        Private Function IEncryptionService_EncryptFile(keyUserId As String, sourceFile As String, encryptedFile As String) As FileInfo Implements IEncryptionService.EncryptFile
            Throw New NotImplementedException()
        End Function

        Private Function IEncryptionService_DecryptFile(encryptedSourceFile As String, decryptedFile As String) As FileInfo Implements IEncryptionService.DecryptFile
            Throw New NotImplementedException()
        End Function
    End Class
End Module



И чтобы зашифровать вызываем следующий код

Код: vbnet
1.
2.
Dim p As New EncryptionService
 Call p.EncryptFile("xxxxxx", fileName, fileNameOut)
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / pgp -шифрование
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]