| View previous topic :: View next topic |
| Author |
Message |
bbelcher Contributor

Joined: 30 Jul 2002 Posts: 172
|
Posted: Wed May 04, 2005 7:08 pm Post subject: Create parity files like quick par |
|
|
I think this could be possible but would it be complicated? I take it you would slice up up a file / files into specific parts then create a parity file?
quote from http://www.wehlus.de/mirror/faq.html
You have 5 data bytes:
D1, D2, D3, D4, D5
Now you want to create a parity byte to restore missing data bytes. What to do? Just add them:
P1=D1+D2+D3+D4+D5
So you have lost D3 and want to recover it? Again, it's simple math:
D3=P1-D1-D2-D4-D5
[/url] |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu May 05, 2005 9:01 am Post subject: |
|
|
I once made some code which could split up a file into two pieces and which made a third file which had the parity information in it. If the original file was 100 MB, the first two pieces were both 50 MB, and the parity file was also 50 MB. It didn't matter which file you lose, because with two of the three files, everything could be regenerated...
I'll post the code as soon as I find it...  _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu May 05, 2005 12:26 pm Post subject: |
|
|
This is the function I made, but it does not save anything to disc and it isn't really fast with large files, but it might be a good start...
| Code: | #define command,Safebackup
#define function,Safebackup
%%Text = "Hello, this is just some text which has to be saved secure, without having to worry about it getting deleted by accident."
# Call the Safebackup command with the text or value which should be splitted apart.
Safebackup %%Text
# Now, you can safe the content of the variables "%%Split_Output_1", "%%Split_Output_2"
# and "%%Split_Output_3" to different files on different folders, partitions or "real"
# discdrives.
info Backup made!
# When you want to rejoin the file or text, you can call the @Safebackup() function
# like below:
info @Safebackup(%%Split_Output_1,%%Split_Output_2)
info @Safebackup(%%Split_Output_1,,%%Split_Output_3)
info @Safebackup(,%%Split_Output_2,%%Split_Output_3)
# This will show the three variables which should be saved...
info %%Split_Output_1@cr()@cr()%%Split_Output_2@cr()@cr()%%Split_Output_3
exit
:Safebackup
# The first IF command will only trigger if the second and third parameter are
# not specified. It will split the input text into three variables, called:
#
# %%Split_Output_1
# %%Split_Output_2
# %%Split_Output_3
#
# You can save the values of these three variables to three different harddisc
# drives or three different folders and/or partitions on the same drive. This way,
# if one of these files gets corrupted, you can rejoin the other two files into
# the original one.
if @both(@equal(%2,),@equal(%3,))
%%Split_Output_1 =
%%Split_Output_2 =
%%Split_Output_3 =
if @unequal(@mod(@len(%1),2),0)
%1 = %1@chr(32)
end
repeat
%%Split_Output_1 = %%Split_Output_1@substr(%1,1,1)
%%Split_Output_2 = %%Split_Output_2@substr(%1,2,2)
%%Temp_Split = @sum(@asc(@substr(%1,1,1)),@asc(@substr(%1,2,2)))
if @greater(%%Temp_Split,255)
%%Split_Output_3 = %%Split_Output_3@chr(@diff(%%Temp_Split,255))
else
%%Split_Output_3 = %%Split_Output_3@chr(%%Temp_Split)
end
%1 = @strdel(%1,1,2)
until @equal(@len(%1),0)
exit
end
# This will join the value of the %%Split_Output_1 and %%Split_Output_2 variables
# (first and second parameter) together.
if @both(@unequal(%1,),@unequal(%2,))
%%Join_Output =
repeat
%%Join_Output = %%Join_Output@substr(%1,1,1)@substr(%2,1,1)
%1 = @strdel(%1,1,1)
%2 = @strdel(%2,1,1)
until @equal(@len(%1),0)
exit @trim(%%Join_Output)
end
# This will join the value of the %%Split_Output_1 and %%Split_Output_3 variables
# (first and third parameter) together.
if @both(@unequal(%1,),@unequal(%3,))
%%Join_Output =
repeat
%%Join_Output = %%Join_Output@substr(%1,1,1)@chr(@diff(@asc(@substr(%3,1,1)),@asc(@substr(%1,1,1))))
%1 = @strdel(%1,1,1)
%3 = @strdel(%3,1,1)
until @equal(@len(%1),0)
exit @trim(%%Join_Output)
end
# This will join the value of the %%Split_Output_2 and %%Split_Output_3 variables
# (second and third parameter) together.
if @both(@unequal(%2,),@unequal(%3,))
%%Join_Output =
repeat
%%Join_Output = %%Join_Output@chr(@diff(@asc(@substr(%3,1,1)),@asc(@substr(%2,1,1))))@substr(%2,1,1)
%2 = @strdel(%2,1,1)
%3 = @strdel(%3,1,1)
until @equal(@len(%2),0)
exit @trim(%%Join_Output)
end
exit |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|