gpt4 book ai didi

vb.net - 如何将加密的音频文件解密到剪贴板

转载 作者:行者123 更新时间:2023-12-03 01:56:07 26 4
gpt4 key购买 nike

我想知道是否有可能将加密的音频文件解密到剪贴板(而不是解密到新文件)中,然后播放。我尝试编写一些代码,但是由于我对Visual Basic的了解不足,因此出现了错误。我在Google上进行了搜索,但似乎有关加密音频文件的信息并不多。有人能帮助我吗?
我发布代码:

Imports System.Security.Cryptography
Imports System.IO
Imports System.Text

Public Class Form1

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim rij As New RijndaelManaged()
rij.IV = New [Byte]() {2, 23, 35, 83, 7, 35, 28, 34, 94, 25, 45, 2, 73, 26, 27, 78}
Dim pwd As Byte() = New Byte(14) {}
UTF8Encoding.UTF8.GetBytes("123abc").CopyTo(pwd, 0)

'Up to this point is working

My.Computer.Clipboard.Clear()

Dim cs As New CryptoStream(File.OpenRead("C:\Users\User\Desktop\bbb.wav"),
rij.CreateDecryptor(pwd, rij.IV), CryptoStreamMode.Read)

Dim ms As MemoryStream = New MemoryStream()
cs.CopyTo(ms)

GetStreamAsByteArray(ms)

My.Computer.Clipboard.SetAudio(ms)
If My.Computer.Clipboard.ContainsAudio Then
My.Computer.Audio.Play(ms, AudioPlayMode.Background)
End If

End Sub

Private Function GetStreamAsByteArray(ByVal stream As MemoryStream) As Byte()
Dim streamLength As Integer = Convert.ToInt32(stream.Length)
Dim fileData As Byte() = New Byte(streamLength) {}
stream.Read(fileData, 0, streamLength)
stream.Flush()
stream.Close()
Return stream.ToArray()
End Function

End Class

最佳答案

这样比较好,但是...如果我想播放mp3音频文件...没有机会吗?

Clipboard.Clear()            'clear the clipboard
Clipboard.SetAudio(mp3Bytes) 'set the mp3 audio file bytes to the clipboard
If Clipboard.ContainsAudio Then
Dim btsFromClipboard() As Byte = {}
Using cbstrm As Stream = Clipboard.GetAudioStream
ReDim btsFromClipboard(CInt(cbstrm.Length) - 1)
cbstrm.Read(btsFromClipboard, 0, CInt(cbstrm.Length))
End Using

'Now I would like to play the mp3 audio file (just decrypted) by getting the audio file bytes from the clipboard

AxWindowsMediaPlayer1.Ctlcontrols.play() ' ???? I don't know how to go on

End If

关于vb.net - 如何将加密的音频文件解密到剪贴板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35423590/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com