-
2013. 4. 17. 14:27 프로그래밍 언어/Basic
이 예문를 참고 하세요
dim dest_enc as string, dest_dec as string
dim ret as long
ret = encodeLZMA("문자열",dest_enc)
ret = decodeLZMA(dest_dec,dest_enc)
Public Function encodeLZMA(ByRef src As String, ByRef dest_enc As String) As Long
Dim dest() As Byte, source() As Byte, Props(4) As Byte
Dim d As Long, i As Long, l As Long
l = Len(src)
ReDim dest(1024 * (l \ 1024 + 1)) As Byte ' 1kb per area
source = CStr(src)
encodeLZMA = VB_LzmaCompress(dest, source, Props)
dest_enc = String$(encodeLZMA * 2 + 10, 0)
d = encodeLZMA * 2 + 1
For i = 0 To 4
If Props(i) >= 16 Then
Mid$(dest_enc, d) = Hex$(Props(i))
d = d + 2
Else
Mid$(dest_enc, d) = "0"
d = d + 1
Mid$(dest_enc, d) = Hex$(Props(i))
d = d + 1
End If
Next
d = d Xor d: d = d + 1
For i = 0 To encodeLZMA - 1
If dest(i) >= 16 Then
Mid$(dest_enc, d) = Hex$(dest(i))
d = d + 2
Else
Mid$(dest_enc, d) = "0"
d = d + 1
Mid$(dest_enc, d) = Hex$(dest(i))
d = d + 1
End If
Next
End Function
Public Function decodeLZMA(ByRef src As String, ByRef dest_dec As String) As Long
Dim dest() As Byte, source() As Byte, Props(4) As Byte
Dim d As Long, i As Long, l As Long
l = Len(src)
ReDim dest(1024 * (l \ 1024 + 1)) As Byte ' 1kb per area
d = l - 1
For i = 4 To 0 Step -1
Props(i) = str$("&H" & Mid$(src, d, 2))
d = d - 2
Next
d = d + 1
l = d \ 2
ReDim source(l) As Byte
d = d Xor d: d = d + 1
For i = 0 To l - 1
source(i) = str$("&H" & Mid$(src, d, 2))
d = d + 2
Next
decodeLZMA = VB_LzmaUnCompress(dest, source, Props)
dest_dec = CStr(dest)
End Function
dim dest_enc as string, dest_dec as string
dim ret as long
ret = encodeLZMA("문자열",dest_enc)
ret = decodeLZMA(dest_dec,dest_enc)
Public Function encodeLZMA(ByRef src As String, ByRef dest_enc As String) As Long
Dim dest() As Byte, source() As Byte, Props(4) As Byte
Dim d As Long, i As Long, l As Long
l = Len(src)
ReDim dest(1024 * (l \ 1024 + 1)) As Byte ' 1kb per area
source = CStr(src)
encodeLZMA = VB_LzmaCompress(dest, source, Props)
dest_enc = String$(encodeLZMA * 2 + 10, 0)
d = encodeLZMA * 2 + 1
For i = 0 To 4
If Props(i) >= 16 Then
Mid$(dest_enc, d) = Hex$(Props(i))
d = d + 2
Else
Mid$(dest_enc, d) = "0"
d = d + 1
Mid$(dest_enc, d) = Hex$(Props(i))
d = d + 1
End If
Next
d = d Xor d: d = d + 1
For i = 0 To encodeLZMA - 1
If dest(i) >= 16 Then
Mid$(dest_enc, d) = Hex$(dest(i))
d = d + 2
Else
Mid$(dest_enc, d) = "0"
d = d + 1
Mid$(dest_enc, d) = Hex$(dest(i))
d = d + 1
End If
Next
End Function
Public Function decodeLZMA(ByRef src As String, ByRef dest_dec As String) As Long
Dim dest() As Byte, source() As Byte, Props(4) As Byte
Dim d As Long, i As Long, l As Long
l = Len(src)
ReDim dest(1024 * (l \ 1024 + 1)) As Byte ' 1kb per area
d = l - 1
For i = 4 To 0 Step -1
Props(i) = str$("&H" & Mid$(src, d, 2))
d = d - 2
Next
d = d + 1
l = d \ 2
ReDim source(l) As Byte
d = d Xor d: d = d + 1
For i = 0 To l - 1
source(i) = str$("&H" & Mid$(src, d, 2))
d = d + 2
Next
decodeLZMA = VB_LzmaUnCompress(dest, source, Props)
dest_dec = CStr(dest)
End Function