Arama butonu
Bu konudaki kullanıcılar: 1 misafir
2
Cevap
1206
Tıklama
0
Öne Çıkarma
Şifre oluşturma şifreyi çözme Encrypt and Dencrypt
E
14 yıl
Teğmen
Konu Sahibi

Merhaba, arkadaşlar bir sorum olacak
bir kod lazım belirli bir kelimeyi şifreleyecek ve şifreyi geri çözecek. aşağıda bir kod buldum ve şifreleme ve geri çözme yapıyor
fakat oluşturduğı şifre çok uzun örnek
6H0LHAjU3+xYPdeC6owmtA== 
gibi


benim istediğim bu şekilde şifreleme ve şifreyi çözme işlemi yapacak fakat birde şifre uzunluğunu secebileceğim bir kod lazım yardımcı olmanızı rica ederim.


 
Public Function Encrypt(plainText As String, passPhrase As String, saltValue As String, passwordIterations As Integer, initVector As String, keySize As Integer) As String
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim plainTextBytes As Byte() = Encoding.UTF8.GetBytes(plainText)
Dim password As New Rfc2898DeriveBytes(passPhrase, saltValueBytes, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize / 8)
Dim symmetricKey As New RijndaelManaged()
symmetricKey.Mode = CipherMode.CBC
Dim encryptor As ICryptoTransform = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes)
Dim memoryStream As New MemoryStream()
Dim cryptoStream As New CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length)
cryptoStream.FlushFinalBlock()
Dim cipherTextBytes As Byte() = memoryStream.ToArray()
memoryStream.Close()
cryptoStream.Close()
Dim cipherText As String = Convert.ToBase64String(cipherTextBytes)
Return cipherText
End Function
Public Function Decrypt(cipherText As String, passPhrase As String, saltValue As String, passwordIterations As Integer, initVector As String, keySize As Integer) As String
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim cipherTextBytes As Byte() = Convert.FromBase64String(cipherText)
Dim password As New Rfc2898DeriveBytes(passPhrase, saltValueBytes, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize / 8)
Dim symmetricKey As New RijndaelManaged()
symmetricKey.Mode = CipherMode.CBC
Dim decryptor As ICryptoTransform = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes)
Dim memoryStream As New MemoryStream(cipherTextBytes)
Dim cryptoStream As New CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)
Dim plainTextBytes As Byte() = New Byte(cipherTextBytes.Length) {}
Dim decryptedByteCount As Integer = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length)
memoryStream.Close()
cryptoStream.Close()
Dim plainText As String = Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount)
Return plainText
End Function



U
14 yıl
Binbaşı

Şifre uzunluğunu seçmek diye birşey olmaz, belirli algoritmalar vardır, onlardan birini seçersin. O algoritma da sana kendi sonucunu döndürür, uzunluğunu seçemezsin.


Bu mesaja 1 cevap geldi.
E
14 yıl
Teğmen
Konu Sahibi

peki burada 24 bit bir şifre veriyor bunun 12 bitlik yada benzer daha düşük algoritma olanlari varmı?



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.