Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function Decrypt(EncryptedPasswordBytes as byte()) as SecureString
- Dim Store As New X509Store(StoreName.TrustedPublisher,StoreLocation.LocalMachine)
- Store.Open(OpenFlags.ReadOnly)
- Dim Cert = Store.Certificates.Find(X509FindType.FindByThumbprint,
- "0ed0cfd7ffbeb3794013d03c8022f5ed7b45678", False)(0)
- Dim PrivateKey = Cert.GetRSAPrivateKey
- Dim DecryptedPasswordBytes = PrivateKey.Decrypt(EncryptedPasswordBytes,
- Security.Cryptography.RSAEncryptionPadding.OaepSHA256)
- Dim DecryptedPasswordChars = Encoding.UTF8.GetChars(DecryptedPasswordBytes)
- Array.Clear(DecryptedPasswordBytes, 0, DecryptedAppRolePasswordBytes.Length)
- Dim SString As New SecureString
- For Each C In DecryptedAppRolePasswordChars
- SString.AppendChar(C)
- Next
- Array.Clear(DecryptedPasswordChars, 0, DecryptedPasswordChars.Length)
- SString.MakeReadOnly()
- Return SString
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement