ROSTAM2
یک شنبه 26 فروردین 1403, 15:34 عصر
سلام
این دومین دستور رمزگذاری متن هست که من به اشتراک می گذارم (اولیش این بوده: آموزش: تبدیل پسور کاربر به متن امن برای ذخیره در دیتابیس (https://barnamenevis.org/showthread.php?575902-%D8%AA%D8%A8%D8%AF%DB%8C%D9%84-%D9%BE%D8%B3%D9%88%D8%B1-%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1-%D8%A8%D9%87-%D9%85%D8%AA%D9%86-%D8%A7%D9%85%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%B0%D8%AE%DB%8C%D8%B1%D9%87-%D8%AF%D8%B1-%D8%AF%DB%8C%D8%AA%D8%A7%D8%A8%DB%8C%D8%B3)) و کد ساده ای داره و برای رمزگذاری کلیدواژهای موقت می شه استفاده کرد.
مراجع مورد نیاز:
Imports System.Security.Cryptography
Imports System.Text
متغیرهای با سطح دسترسی در ماجول کد:
'Create a UnicodeEncoder to convert between byte array and string.
Dim ByteConverter As New ASCIIEncoding
'Create a new instance of the RSACryptoServiceProvider class
' and automatically create a new key-pair.
Dim RSAalg As New RSACryptoServiceProvider
رمز گذاری متن TextBox1 و ذخیره سازی در رجیستری بصورت Binary:
Dim dataToEncrypt As Byte() = ByteConverter.GetBytes(Me.TextBox1.Text)
Dim encryptedData() As Byte = RSAalg.Encrypt(dataToEncrypt, False)
With Microsoft.Win32.Registry.CurrentUser.OpenSubKey("System", True)
.SetValue("Password", encryptedData, Microsoft.Win32.RegistryValueKind.Binary)
End With
فراخوانی مقدار ذخیره سازی شده از رجیستری و رمزگشایی مقدار و نمایش متن رمزگشایی دشه در TextBox2:
Dim decryptedData() As Byte
Dim encryptedData() As Byte
With Microsoft.Win32.Registry.CurrentUser.OpenSubKey("System", True)
encryptedData = .GetValue("Password", New Byte() {})
End With
decryptedData = RSAalg.Decrypt(encryptedData, False)
Me.TextBox3.Text = ByteConverter.GetString(decryptedData)
کد کامل در پست بعدی....
این دومین دستور رمزگذاری متن هست که من به اشتراک می گذارم (اولیش این بوده: آموزش: تبدیل پسور کاربر به متن امن برای ذخیره در دیتابیس (https://barnamenevis.org/showthread.php?575902-%D8%AA%D8%A8%D8%AF%DB%8C%D9%84-%D9%BE%D8%B3%D9%88%D8%B1-%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1-%D8%A8%D9%87-%D9%85%D8%AA%D9%86-%D8%A7%D9%85%D9%86-%D8%A8%D8%B1%D8%A7%DB%8C-%D8%B0%D8%AE%DB%8C%D8%B1%D9%87-%D8%AF%D8%B1-%D8%AF%DB%8C%D8%AA%D8%A7%D8%A8%DB%8C%D8%B3)) و کد ساده ای داره و برای رمزگذاری کلیدواژهای موقت می شه استفاده کرد.
مراجع مورد نیاز:
Imports System.Security.Cryptography
Imports System.Text
متغیرهای با سطح دسترسی در ماجول کد:
'Create a UnicodeEncoder to convert between byte array and string.
Dim ByteConverter As New ASCIIEncoding
'Create a new instance of the RSACryptoServiceProvider class
' and automatically create a new key-pair.
Dim RSAalg As New RSACryptoServiceProvider
رمز گذاری متن TextBox1 و ذخیره سازی در رجیستری بصورت Binary:
Dim dataToEncrypt As Byte() = ByteConverter.GetBytes(Me.TextBox1.Text)
Dim encryptedData() As Byte = RSAalg.Encrypt(dataToEncrypt, False)
With Microsoft.Win32.Registry.CurrentUser.OpenSubKey("System", True)
.SetValue("Password", encryptedData, Microsoft.Win32.RegistryValueKind.Binary)
End With
فراخوانی مقدار ذخیره سازی شده از رجیستری و رمزگشایی مقدار و نمایش متن رمزگشایی دشه در TextBox2:
Dim decryptedData() As Byte
Dim encryptedData() As Byte
With Microsoft.Win32.Registry.CurrentUser.OpenSubKey("System", True)
encryptedData = .GetValue("Password", New Byte() {})
End With
decryptedData = RSAalg.Decrypt(encryptedData, False)
Me.TextBox3.Text = ByteConverter.GetString(decryptedData)
کد کامل در پست بعدی....