hiya all,
Just wondering how to use vb to encrypt a bitmap file and then be able to decrypt it, it doesnt have to be the best encryption.
Thanks
Printable View
hiya all,
Just wondering how to use vb to encrypt a bitmap file and then be able to decrypt it, it doesnt have to be the best encryption.
Thanks
Use this function.
Since it's binary encryption with Xor, this will do both Encryption and Decryption.Code:Sub Encrypt(ByVal sName As String)
Dim b() As Byte
Dim nb() As Byte
n = FileLen(sName)
ReDim b(n - 1)
ReDim nb(n - 1)
Open sName For Binary Access Read As #1
Get #1, , b()
Close #1
Kill sName
For i = LBound(b) To UBound(b)
nb(i) = b(i) Xor 5
Next i
Open sName For Binary Access Write As #1
Put #1, , nb()
Close #1
End Sub
Usage:
Code:Encrypt "MyFile.bmp"
cheers megaman :D